From e660ea90cc2553c53dbc702ccb49de26916a9eec Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Fri, 27 Dec 2019 19:27:48 +0100 Subject: [PATCH] fix(Webhook): edit channel when editing avatar (#3588) --- src/structures/Webhook.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/structures/Webhook.js b/src/structures/Webhook.js index b4c228e97..9b6b43c8f 100644 --- a/src/structures/Webhook.js +++ b/src/structures/Webhook.js @@ -194,20 +194,20 @@ class Webhook { * @param {string} [reason] Reason for editing this webhook * @returns {Promise} */ - edit({ name = this.name, avatar, channel }, reason) { + async edit({ name = this.name, avatar, channel }, reason) { if (avatar && (typeof avatar === 'string' && !avatar.startsWith('data:'))) { - return DataResolver.resolveImage(avatar).then(image => this.edit({ name, avatar: image }, reason)); + avatar = await DataResolver.resolveImage(avatar); } if (channel) channel = channel instanceof Channel ? channel.id : channel; - return this.client.api.webhooks(this.id, channel ? undefined : this.token).patch({ + const data = await this.client.api.webhooks(this.id, channel ? undefined : this.token).patch({ data: { name, avatar, channel_id: channel }, reason, - }).then(data => { - this.name = data.name; - this.avatar = data.avatar; - this.channelID = data.channel_id; - return this; }); + + this.name = data.name; + this.avatar = data.avatar; + this.channelID = data.channel_id; + return this; } /**