Add role support to emoji creation (#1141)

* add role support to emojis

* specify types
This commit is contained in:
Gus Caplan
2017-01-30 21:47:27 -06:00
committed by Schuyler Cebulskie
parent 18729b25c7
commit 565c640bc6
2 changed files with 9 additions and 6 deletions

View File

@@ -682,6 +682,7 @@ class Guild {
* Creates a new custom emoji in the guild.
* @param {BufferResolvable|Base64Resolvable} attachment The image for the emoji.
* @param {string} name The name for the emoji.
* @param {Collection<Role>|Role[]} [roles] Roles to limit the emoji to
* @returns {Promise<Emoji>} The created emoji.
* @example
* // create a new emoji from a url
@@ -694,13 +695,13 @@ class Guild {
* .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
* .catch(console.error);
*/
createEmoji(attachment, name) {
createEmoji(attachment, name, roles) {
return new Promise(resolve => {
if (typeof attachment === 'string' && attachment.startsWith('data:')) {
resolve(this.client.rest.methods.createEmoji(this, attachment, name));
resolve(this.client.rest.methods.createEmoji(this, attachment, name, roles));
} else {
this.client.resolver.resolveBuffer(attachment).then(data =>
resolve(this.client.rest.methods.createEmoji(this, data, name))
resolve(this.client.rest.methods.createEmoji(this, data, name, roles))
);
}
});