From c6f9c50ba9abf9555a2c40de3113a08765b830d5 Mon Sep 17 00:00:00 2001 From: Mohamed Ashraf <55748253+dager-mohamed@users.noreply.github.com> Date: Sat, 18 Feb 2023 01:35:44 +0200 Subject: [PATCH] feat(core): Adds `getWebhooks()` function for the channel API and for the guild API (#9043) * feat(core): Adds `getChannel()` for webhooks * feat(core): add `getWebhooks()` function for the channel and the guild * Update packages/core/src/api/guild.ts Co-authored-by: Almeida * Update packages/core/src/api/channel.ts Co-authored-by: Almeida * Update packages/core/src/api/channel.ts Co-authored-by: Almeida * Update packages/core/src/api/guild.ts Co-authored-by: Almeida * Update packages/core/src/api/guild.ts Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * Update packages/core/src/api/channel.ts Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * sorting the types --------- Co-authored-by: Almeida Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: space --- packages/core/src/api/channel.ts | 11 +++++++++++ packages/core/src/api/guild.ts | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/packages/core/src/api/channel.ts b/packages/core/src/api/channel.ts index 382d05a94..2d56fba71 100644 --- a/packages/core/src/api/channel.ts +++ b/packages/core/src/api/channel.ts @@ -12,6 +12,7 @@ import { type RESTGetAPIChannelResult, type RESTGetAPIChannelThreadsArchivedQuery, type RESTGetAPIChannelUsersThreadsArchivedResult, + type RESTGetAPIChannelWebhooksResult, type RESTPatchAPIChannelJSONBody, type RESTPatchAPIChannelMessageResult, type RESTPatchAPIChannelResult, @@ -349,4 +350,14 @@ export class ChannelsAPI { query: makeURLSearchParams(options), }) as Promise; } + + /** + * Fetches the webhooks of a channel + * + * @see {@link https://discord.com/developers/docs/resources/webhook#get-channel-webhooks} + * @param id - The id of the channel + */ + public async getWebhooks(id: Snowflake) { + return this.rest.get(Routes.channelWebhooks(id)) as Promise; + } } diff --git a/packages/core/src/api/guild.ts b/packages/core/src/api/guild.ts index f51bbf052..fc2b80c9a 100644 --- a/packages/core/src/api/guild.ts +++ b/packages/core/src/api/guild.ts @@ -38,6 +38,7 @@ import { type RESTPostAPIGuildStickerFormDataBody, type RESTPostAPIGuildStickerResult, type RESTGetAPIGuildMembersSearchQuery, + type RESTGetAPIGuildWebhooksResult, type RESTGetAPIGuildWelcomeScreenResult, type RESTGetAPIGuildWidgetImageResult, type RESTGetAPIGuildWidgetJSONResult, @@ -965,4 +966,14 @@ export class GuildsAPI { public async createTemplate(templateCode: string, data: RESTPostAPITemplateCreateGuildJSONBody) { return this.rest.post(Routes.template(templateCode), { body: data }) as Promise; } + + /** + * Fetches webhooks for a guild + * + * @see {@link https://discord.com/developers/docs/resources/webhook#get-guild-webhooks} + * @param id - The id of the guild + */ + public async getWebhooks(id: Snowflake) { + return this.rest.get(Routes.guildWebhooks(id)) as Promise; + } }