From c041b1bc23e8df9075d984af0b754eeb50a8aaaf Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Sun, 13 Nov 2016 01:05:55 -0600 Subject: [PATCH] fix these things (#895) * fix these things * fix enormous stupid --- src/structures/Guild.js | 12 ++++++++---- src/structures/TextChannel.js | 17 +++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 43deeb8c2..f073132f0 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -598,10 +598,14 @@ class Guild { * .catch(console.error); */ createEmoji(attachment, name) { - return this.client.resolver.resolveBuffer(attachment).then(file => { - let base64 = new Buffer(file, 'binary').toString('base64'); - let dataURI = `data:;base64,${base64}`; - return this.client.rest.methods.createEmoji(this, dataURI, name); + return new Promise(resolve => { + if (attachment.startsWith('data:')) { + resolve(this.client.rest.methods.createEmoji(this, attachment, name)); + } else { + this.client.resolver.resolveBuffer(attachment).then(data => + resolve(this.client.rest.methods.createEmoji(this, data, name)) + ); + } }); } diff --git a/src/structures/TextChannel.js b/src/structures/TextChannel.js index cd067714f..74c0ff2d0 100644 --- a/src/structures/TextChannel.js +++ b/src/structures/TextChannel.js @@ -61,14 +61,15 @@ class TextChannel extends GuildChannel { * .catch(console.error) */ createWebhook(name, avatar) { - if (avatar) { - return this.client.resolver.resolveBuffer(avatar).then(file => { - let base64 = new Buffer(file, 'binary').toString('base64'); - let dataURI = `data:;base64,${base64}`; - return this.client.rest.methods.createWebhook(this, name, dataURI); - }); - } - return this.client.rest.methods.createWebhook(this, name); + return new Promise(resolve => { + if (avatar.startsWith('data:')) { + resolve(this.client.rest.methods.createWebhook(this, name, avatar)); + } else { + this.client.resolver.resolveBuffer(avatar).then(data => + resolve(this.client.rest.methods.createWebhook(this, name, data)) + ); + } + }); } // These are here only for documentation purposes - they are implemented by TextBasedChannel