Skip to content

Commit

Permalink
feat(Client): deleteWebhook method
Browse files Browse the repository at this point in the history
  • Loading branch information
jaw0r3k committed Aug 16, 2023
1 parent 9ed1b59 commit 3652f05
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/discord.js/src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,23 @@ class Client extends BaseClient {
this.rest.setToken(null);
}

/**
* Options used when deleting a webhook from Discord.
* @typedef {Object} WebhookDeleteOptions
* @property {string} [token] Token of the webhook
* @property {string} [reason] The reason for deleting the webhook
*/

/**
* Deletes a webhook.
* @param {Snowflake} id The webhook's id
* @param {WebhookDeleteOptions} [options] Options for deleting the webhook
* @returns {Promise<void>}
*/
async deleteWebhook(id, { token, reason } = {}) {
await this.rest.delete(Routes.webhook(id, token), { auth: token === undefined, reason });
}

/**
* Options used when fetching an invite from Discord.
* @typedef {Object} ClientFetchInviteOptions
Expand Down
6 changes: 6 additions & 0 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
public voice: ClientVoiceManager;
public ws: WebSocketManager;
public destroy(): Promise<void>;
public deleteWebhook(id: Snowflake, options?: WebhookDeleteOptions): Promise<void>;
public fetchGuildPreview(guild: GuildResolvable): Promise<GuildPreview>;
public fetchInvite(invite: InviteResolvable, options?: ClientFetchInviteOptions): Promise<Invite>;
public fetchGuildTemplate(template: GuildTemplateResolvable): Promise<GuildTemplate>;
Expand Down Expand Up @@ -6397,6 +6398,11 @@ export interface WebhookClientDataURL {

export type WebhookClientOptions = Pick<ClientOptions, 'allowedMentions' | 'rest'>;

export interface WebhookDeleteOptions {
token?: string;
reason?: string;
}

export interface WebhookEditOptions {
name?: string;
avatar?: BufferResolvable | null;
Expand Down

0 comments on commit 3652f05

Please sign in to comment.