Files
discordeno/helpers/channels/threads/getActiveThreads.ts
ITOH b00504ce07 perf(plugins/helpers,rest,site,template)!: uppercase rest methods (#2252)
* perf(plugins/helpers,rest,site,template)!: uppercase rest methods
There is no need for us to pass the methods in lower case and then use the `toUpperCase()` method everywhere. Therefore this PR changes every lowercase method to be uppercase (eg. `"get"` => `"GET"`).

* template is old version
2022-05-25 20:45:51 +02:00

28 lines
914 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.routes.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];
}),
),
};
}