Files
discordeno/src/helpers/webhooks/get_webhooks.ts
2021-10-25 18:35:39 +00:00

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]));
}