Files
discordeno/plugins/bot/helpers/channels/threads/getThreadMembers.ts
T
Skillz4Killz ffe7cdbc6f feat: base plugin lib idea (#2308)
* feat: base plugin lib idea

* fix: stuff

* fmt

* fix: imports and exports

* fix: errors & tests

* fix: remove logs
2022-06-18 18:46:37 -04:00

19 lines
625 B
TypeScript

import { Bot } from "../../../bot.ts";
import { DiscordThreadMember } from "../../../deps.ts";
import { BotCollection as Collection } from "../../../util/collection.ts";
/** Returns thread members objects that are members of the thread. */
export async function getThreadMembers(bot: Bot, threadId: bigint) {
const result = await bot.rest.runMethod<DiscordThreadMember[]>(
bot.rest,
"GET",
bot.constants.routes.THREAD_MEMBERS(threadId),
);
// return result;
return new Collection(result.map((res) => {
const member = bot.transformers.threadMember(bot, res);
return [member.id, member];
}));
}