From 2c14a3f6b00b5fb6dbf9ae88f1613d31207c4f15 Mon Sep 17 00:00:00 2001 From: ayntee Date: Thu, 11 Mar 2021 18:01:21 +0400 Subject: [PATCH] feat(handlers/message): change getReactions() to use collection (#655) * feat(handlers/message): change getReactions() to use collection * deno fmt --- src/api/handlers/message.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/api/handlers/message.ts b/src/api/handlers/message.ts index 7c6bf553b..deceb5694 100644 --- a/src/api/handlers/message.ts +++ b/src/api/handlers/message.ts @@ -7,6 +7,7 @@ import { MessageCreateOptions, UserPayload, } from "../../types/mod.ts"; +import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; import { botHasChannelPermissions } from "../../util/permissions.ts"; import { delay } from "../../util/utils.ts"; @@ -270,15 +271,12 @@ export async function getReactions( reaction: string, options?: DiscordGetReactionsParams, ) { - const result = (await RequestManager.get( + const users = (await RequestManager.get( endpoints.CHANNEL_MESSAGE_REACTION(message.channelID, message.id, reaction), options, )) as UserPayload[]; - return Promise.all(result.map(async (res) => { - const member = await cacheHandlers.get("members", res.id); - return member || res; - })); + return new Collection(users.map((user) => [user.id, user])); } /** Edit the message. */