mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
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>
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const EventEmitter = require('node:events');
|
const EventEmitter = require('node:events');
|
||||||
const { REST } = require('@discordjs/rest');
|
const { REST } = require('@discordjs/rest');
|
||||||
|
const { Routes } = require('discord-api-types/v10');
|
||||||
const { DiscordjsTypeError, ErrorCodes } = require('../errors');
|
const { DiscordjsTypeError, ErrorCodes } = require('../errors');
|
||||||
const Options = require('../util/Options');
|
const Options = require('../util/Options');
|
||||||
const { mergeDefault, flatten } = require('../util/Util');
|
const { mergeDefault, flatten } = require('../util/Util');
|
||||||
@@ -48,6 +49,23 @@ class BaseClient extends EventEmitter {
|
|||||||
this.rest.clearHandlerSweeper();
|
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.
|
* Increments max listeners by one, if they are not zero.
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
@@ -255,23 +255,6 @@ class Client extends BaseClient {
|
|||||||
this.rest.setToken(null);
|
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.
|
* Options used when fetching an invite from Discord.
|
||||||
* @typedef {Object} ClientFetchInviteOptions
|
* @typedef {Object} ClientFetchInviteOptions
|
||||||
|
|||||||
Reference in New Issue
Block a user