feat(handlers/message): change getReactions() to use collection (#655)

* feat(handlers/message): change getReactions() to use collection

* deno fmt
This commit is contained in:
ayntee
2021-03-11 18:01:21 +04:00
committed by GitHub
parent ba2363618e
commit 2c14a3f6b0
+3 -5
View File
@@ -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. */