mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
Update get_channel_webhooks.ts
This commit is contained in:
@@ -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]),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user