diff --git a/packages/discord.js/src/client/BaseClient.js b/packages/discord.js/src/client/BaseClient.js index 631748c92506..5f8e492f0bf1 100644 --- a/packages/discord.js/src/client/BaseClient.js +++ b/packages/discord.js/src/client/BaseClient.js @@ -2,6 +2,7 @@ const EventEmitter = require('node:events'); const { REST } = require('@discordjs/rest'); +const { Routes } = require('discord-api-types/v10'); const { DiscordjsTypeError, ErrorCodes } = require('../errors'); const Options = require('../util/Options'); const { mergeDefault, flatten } = require('../util/Util'); @@ -48,6 +49,23 @@ class BaseClient extends EventEmitter { this.rest.clearHandlerSweeper(); } + /** + * Options used for deleting a webhook. + * @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} + */ + async deleteWebhook(id, { token, reason } = {}) { + await this.rest.delete(Routes.webhook(id, token), { auth: !token, reason }); + } + /** * Increments max listeners by one, if they are not zero. * @private diff --git a/packages/discord.js/src/client/Client.js b/packages/discord.js/src/client/Client.js index 92b23cbf6fe4..20fdff4f4f05 100644 --- a/packages/discord.js/src/client/Client.js +++ b/packages/discord.js/src/client/Client.js @@ -255,23 +255,6 @@ class Client extends BaseClient { this.rest.setToken(null); } - /** - * Options used for deleting a webhook. - * @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} - */ - async deleteWebhook(id, { token, reason } = {}) { - await this.rest.delete(Routes.webhook(id, token), { auth: !token, reason }); - } - /** * Options used when fetching an invite from Discord. * @typedef {Object} ClientFetchInviteOptions