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 <almeidx@pm.me>

* Update packages/core/src/api/channel.ts

Co-authored-by: Almeida <almeidx@pm.me>

* Update packages/core/src/api/channel.ts

Co-authored-by: Almeida <almeidx@pm.me>

* Update packages/core/src/api/guild.ts

Co-authored-by: Almeida <almeidx@pm.me>

* 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 <almeidx@pm.me>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: space <spaceeec@yahoo.com>
This commit is contained in:
Mohamed Ashraf
2023-02-18 01:35:44 +02:00
committed by GitHub
parent 765d5a3b2d
commit c6f9c50ba9
2 changed files with 22 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ import {
type RESTGetAPIChannelResult, type RESTGetAPIChannelResult,
type RESTGetAPIChannelThreadsArchivedQuery, type RESTGetAPIChannelThreadsArchivedQuery,
type RESTGetAPIChannelUsersThreadsArchivedResult, type RESTGetAPIChannelUsersThreadsArchivedResult,
type RESTGetAPIChannelWebhooksResult,
type RESTPatchAPIChannelJSONBody, type RESTPatchAPIChannelJSONBody,
type RESTPatchAPIChannelMessageResult, type RESTPatchAPIChannelMessageResult,
type RESTPatchAPIChannelResult, type RESTPatchAPIChannelResult,
@@ -349,4 +350,14 @@ export class ChannelsAPI {
query: makeURLSearchParams(options), query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIChannelUsersThreadsArchivedResult>; }) as Promise<RESTGetAPIChannelUsersThreadsArchivedResult>;
} }
/**
* 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<RESTGetAPIChannelWebhooksResult>;
}
} }

View File

@@ -38,6 +38,7 @@ import {
type RESTPostAPIGuildStickerFormDataBody, type RESTPostAPIGuildStickerFormDataBody,
type RESTPostAPIGuildStickerResult, type RESTPostAPIGuildStickerResult,
type RESTGetAPIGuildMembersSearchQuery, type RESTGetAPIGuildMembersSearchQuery,
type RESTGetAPIGuildWebhooksResult,
type RESTGetAPIGuildWelcomeScreenResult, type RESTGetAPIGuildWelcomeScreenResult,
type RESTGetAPIGuildWidgetImageResult, type RESTGetAPIGuildWidgetImageResult,
type RESTGetAPIGuildWidgetJSONResult, type RESTGetAPIGuildWidgetJSONResult,
@@ -965,4 +966,14 @@ export class GuildsAPI {
public async createTemplate(templateCode: string, data: RESTPostAPITemplateCreateGuildJSONBody) { public async createTemplate(templateCode: string, data: RESTPostAPITemplateCreateGuildJSONBody) {
return this.rest.post(Routes.template(templateCode), { body: data }) as Promise<RESTPostAPIGuildTemplatesResult>; return this.rest.post(Routes.template(templateCode), { body: data }) as Promise<RESTPostAPIGuildTemplatesResult>;
} }
/**
* 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<RESTGetAPIGuildWebhooksResult>;
}
} }