Update get_channel_webhooks.ts

This commit is contained in:
ITOH
2021-04-23 23:27:35 +02:00
parent f733a36051
commit ecc0418271
+4 -8
View File
@@ -1,23 +1,19 @@
import { rest } from "../../rest/rest.ts";
import { DiscordWebhook, Webhook } from "../../types/webhooks/webhook.ts";
import { Webhook } from "../../types/webhooks/webhook.ts";
import { Collection } from "../../util/collection.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotChannelPermissions } from "../../util/permissions.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
/** Gets the webhooks for this channel. Requires MANAGE_WEBHOOKS */
export async function getChannelWebhooks(channelId: string) {
await requireBotChannelPermissions(channelId, ["MANAGE_WEBHOOKS"]);
const result = (await rest.runMethod(
const result = await rest.runMethod<Webhook[]>(
"get",
endpoints.CHANNEL_WEBHOOKS(channelId),
)) as DiscordWebhook[];
);
return new Collection(
result.map((webhook) => [
webhook.id,
snakeKeysToCamelCase<Webhook>(webhook),
]),
result.map((webhook) => [webhook.id, webhook]),
);
}