mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-30 23:40:07 +00:00
* fix: check new types idea * fix: type errors * fix: new style * fix: more cleanup * fix: more cleanup * fix: cleanup audit logs * fix: cleanup stickers * fix: cleanup integrations * fix: more cleanup * fix: organize into 1 place * fix: few errors * fix: some broken import fixes * fix: quite a lot of fixes across the board * fix: more fixes for broken imports * fix: more fixes for broken imports * fix: handler imports * fix: all remaining import errors * fix: more errors needing fixes * fix: clearing up transformers * fix: few moer types * fix: more cleanup of extra types * fix: fmt * fix: cleanup discordeno file * Nuke Base Types (#2102) * fix: cleanup snake stuff * convert camelCase to snake_case (#2103) * fix: add camelize * fix: finalize remaining errors * fix: imports in test Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com>
28 lines
917 B
TypeScript
28 lines
917 B
TypeScript
import type { Bot } from "../../../bot.ts";
|
|
import { DiscordListActiveThreads } from "../../../types/discord.ts";
|
|
import { Collection } from "../../../util/collection.ts";
|
|
|
|
/** Returns all active threads in the guild, including public and private threads. Threads are ordered by their `id`, in descending order. */
|
|
export async function getActiveThreads(bot: Bot, guildId: bigint) {
|
|
const result = await bot.rest.runMethod<DiscordListActiveThreads>(
|
|
bot.rest,
|
|
"get",
|
|
bot.constants.endpoints.THREAD_ACTIVE(guildId),
|
|
);
|
|
|
|
return {
|
|
threads: new Collection(
|
|
result.threads.map((t) => {
|
|
const thread = bot.transformers.channel(bot, { channel: t });
|
|
return [thread.id, thread];
|
|
}),
|
|
),
|
|
members: new Collection(
|
|
result.members.map((m) => {
|
|
const member = bot.transformers.threadMember(bot, m);
|
|
return [member.id, member];
|
|
}),
|
|
),
|
|
};
|
|
}
|