mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
fix(WebhookClient): use applyToClass instead of multiple inheritance (#1896)
This commit is contained in:
@@ -8,21 +8,15 @@ const MessageEmbed = require('./MessageEmbed');
|
||||
* Represents a webhook.
|
||||
*/
|
||||
class Webhook {
|
||||
constructor(client, dataOrID, token) {
|
||||
if (client) {
|
||||
/**
|
||||
* The client that instantiated the webhook
|
||||
* @name Webhook#client
|
||||
* @type {Client}
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(this, 'client', { value: client });
|
||||
if (dataOrID) this._patch(dataOrID);
|
||||
} else {
|
||||
this.id = dataOrID;
|
||||
this.token = token;
|
||||
Object.defineProperty(this, 'client', { value: this });
|
||||
}
|
||||
constructor(client, data) {
|
||||
/**
|
||||
* The client that instantiated the webhook
|
||||
* @name Webhook#client
|
||||
* @type {Client}
|
||||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(this, 'client', { value: client });
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
@@ -274,6 +268,18 @@ class Webhook {
|
||||
delete(reason) {
|
||||
return this.client.api.webhooks(this.id, this.token).delete({ reason });
|
||||
}
|
||||
|
||||
static applyToClass(structure) {
|
||||
for (const prop of [
|
||||
'send',
|
||||
'sendSlackMessage',
|
||||
'edit',
|
||||
'delete',
|
||||
]) {
|
||||
Object.defineProperty(structure.prototype, prop,
|
||||
Object.getOwnPropertyDescriptor(Webhook.prototype, prop));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Webhook;
|
||||
|
||||
Reference in New Issue
Block a user