Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Webhook): do not call client.deleteWebhook in delete #9786

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/discord.js/src/client/BaseClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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<void>}
*/
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
Expand Down
17 changes: 0 additions & 17 deletions packages/discord.js/src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>}
*/
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
Expand Down