Skip to content

Commit 31d914e

Browse files
kyranetalmostSoujikodiakhq[bot]
authored
fix(Webhook): do not call client.deleteWebhook in delete (#9786)
* fix(Webhook): do not call `client.deleteWebhook` in `delete` Partially reverts #9777 which caused a regression (#9785) when using `WebhookClient` * chore: add comment Co-Authored-By: Souji <timoqueezle@gmail.com> * fix: move `deleteWebhook` from `Client` to `BaseClient` --------- Co-authored-by: Souji <timoqueezle@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent efbcda7 commit 31d914e

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

packages/discord.js/src/client/BaseClient.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const EventEmitter = require('node:events');
44
const { REST } = require('@discordjs/rest');
5+
const { Routes } = require('discord-api-types/v10');
56
const { DiscordjsTypeError, ErrorCodes } = require('../errors');
67
const Options = require('../util/Options');
78
const { mergeDefault, flatten } = require('../util/Util');
@@ -48,6 +49,23 @@ class BaseClient extends EventEmitter {
4849
this.rest.clearHandlerSweeper();
4950
}
5051

52+
/**
53+
* Options used for deleting a webhook.
54+
* @typedef {Object} WebhookDeleteOptions
55+
* @property {string} [token] Token of the webhook
56+
* @property {string} [reason] The reason for deleting the webhook
57+
*/
58+
59+
/**
60+
* Deletes a webhook.
61+
* @param {Snowflake} id The webhook's id
62+
* @param {WebhookDeleteOptions} [options] Options for deleting the webhook
63+
* @returns {Promise<void>}
64+
*/
65+
async deleteWebhook(id, { token, reason } = {}) {
66+
await this.rest.delete(Routes.webhook(id, token), { auth: !token, reason });
67+
}
68+
5169
/**
5270
* Increments max listeners by one, if they are not zero.
5371
* @private

packages/discord.js/src/client/Client.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -255,23 +255,6 @@ class Client extends BaseClient {
255255
this.rest.setToken(null);
256256
}
257257

258-
/**
259-
* Options used for deleting a webhook.
260-
* @typedef {Object} WebhookDeleteOptions
261-
* @property {string} [token] Token of the webhook
262-
* @property {string} [reason] The reason for deleting the webhook
263-
*/
264-
265-
/**
266-
* Deletes a webhook.
267-
* @param {Snowflake} id The webhook's id
268-
* @param {WebhookDeleteOptions} [options] Options for deleting the webhook
269-
* @returns {Promise<void>}
270-
*/
271-
async deleteWebhook(id, { token, reason } = {}) {
272-
await this.rest.delete(Routes.webhook(id, token), { auth: !token, reason });
273-
}
274-
275258
/**
276259
* Options used when fetching an invite from Discord.
277260
* @typedef {Object} ClientFetchInviteOptions

0 commit comments

Comments
 (0)