Clean up nearly all promises to utilise chaining, other small fixes

This commit is contained in:
Schuyler Cebulskie
2016-10-30 16:27:28 -04:00
parent 8306d50bd8
commit 60e0d507f0
10 changed files with 482 additions and 620 deletions

View File

@@ -582,7 +582,7 @@ class Guild {
/**
* Creates a new custom emoji in the guild.
* @param {FileResolveable} attachment The image for the emoji.
* @param {FileResolvable} attachment The image for the emoji.
* @param {string} name The name for the emoji.
* @returns {Promise<Emoji>} The created emoji.
* @example
@@ -597,13 +597,10 @@ class Guild {
* .catch(console.error);
*/
createEmoji(attachment, name) {
return new Promise((resolve, reject) => {
this.client.resolver.resolveFile(attachment).then(file => {
let base64 = new Buffer(file, 'binary').toString('base64');
let dataURI = `data:;base64,${base64}`;
this.client.rest.methods.createEmoji(this, dataURI, name)
.then(resolve).catch(reject);
}).catch(reject);
return this.client.resolver.resolveFile(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);
});
}