mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 01:10:07 +00:00
18 lines
677 B
TypeScript
18 lines
677 B
TypeScript
import type { Bot } from "../../bot.ts";
|
|
import type { Webhook } from "../../types/webhooks/webhook.ts";
|
|
import { Collection } from "../../util/collection.ts";
|
|
import type { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
|
|
|
/** Returns a list of guild webhooks objects. Requires the MANAGE_WEBHOOKs permission. */
|
|
export async function getWebhooks(bot: Bot, guildId: bigint) {
|
|
await bot.utils.requireBotGuildPermissions(bot, guildId, ["MANAGE_WEBHOOKS"]);
|
|
|
|
const result = await bot.rest.runMethod<Webhook[]>(
|
|
bot.rest,
|
|
"get",
|
|
bot.constants.endpoints.GUILD_WEBHOOKS(guildId)
|
|
);
|
|
|
|
return new Collection(result.map((webhook) => [webhook.id, webhook]));
|
|
}
|