mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
Update get_channel_webhooks.ts
This commit is contained in:
@@ -1,23 +1,19 @@
|
|||||||
import { rest } from "../../rest/rest.ts";
|
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 { Collection } from "../../util/collection.ts";
|
||||||
import { endpoints } from "../../util/constants.ts";
|
import { endpoints } from "../../util/constants.ts";
|
||||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||||
import { snakeKeysToCamelCase } from "../../util/utils.ts";
|
|
||||||
|
|
||||||
/** Gets the webhooks for this channel. Requires MANAGE_WEBHOOKS */
|
/** Gets the webhooks for this channel. Requires MANAGE_WEBHOOKS */
|
||||||
export async function getChannelWebhooks(channelId: string) {
|
export async function getChannelWebhooks(channelId: string) {
|
||||||
await requireBotChannelPermissions(channelId, ["MANAGE_WEBHOOKS"]);
|
await requireBotChannelPermissions(channelId, ["MANAGE_WEBHOOKS"]);
|
||||||
|
|
||||||
const result = (await rest.runMethod(
|
const result = await rest.runMethod<Webhook[]>(
|
||||||
"get",
|
"get",
|
||||||
endpoints.CHANNEL_WEBHOOKS(channelId),
|
endpoints.CHANNEL_WEBHOOKS(channelId),
|
||||||
)) as DiscordWebhook[];
|
);
|
||||||
|
|
||||||
return new Collection(
|
return new Collection(
|
||||||
result.map((webhook) => [
|
result.map((webhook) => [webhook.id, webhook]),
|
||||||
webhook.id,
|
|
||||||
snakeKeysToCamelCase<Webhook>(webhook),
|
|
||||||
]),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user