From 7f921883f4908082ba54385d8f5fabdbf3d1badf Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Thu, 31 Aug 2017 15:55:05 +0100 Subject: [PATCH] Fix TextChannel#createWebhook --- src/structures/TextChannel.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/structures/TextChannel.js b/src/structures/TextChannel.js index e79b4394e..45796be19 100644 --- a/src/structures/TextChannel.js +++ b/src/structures/TextChannel.js @@ -60,14 +60,13 @@ class TextChannel extends GuildChannel { * .then(webhook => console.log(`Created webhook ${webhook}`)) * .catch(console.error) */ - createWebhook(name, { avatar, reason } = {}) { - if (typeof avatar === 'string' && avatar.startsWith('data:')) { - return this.client.api.channels[this.id].webhooks.post({ data: { - name, avatar, - }, reason }).then(data => new Webhook(this.client, data)); + async createWebhook(name, { avatar, reason } = {}) { + if (typeof avatar === 'string' && !avatar.startsWith('data:')) { + avatar = await this.client.resolver.resolveImage(avatar); } - return this.client.resolver.resolveImage(avatar).then(image => - this.createWebhook(name, { avatar: image, reason })); + return this.client.api.channels[this.id].webhooks.post({ data: { + name, avatar, + }, reason }).then(data => new Webhook(this.client, data)); } // These are here only for documentation purposes - they are implemented by TextBasedChannel