mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
Add role support to emoji creation (#1141)
* add role support to emojis * specify types
This commit is contained in:
committed by
Schuyler Cebulskie
parent
18729b25c7
commit
565c640bc6
@@ -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))
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user