mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Emoji convenience methods (#1378)
* make branch * stuff * Consistency & remove role(s) * kill me * Doc changes Requested by Crawl * forgot 1
This commit is contained in:
@@ -123,6 +123,59 @@ class Emoji {
|
||||
return this.client.rest.methods.updateEmoji(this, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the emoji.
|
||||
* @param {string} name The new name for the emoji
|
||||
* @returns {Promise<Emoji>}
|
||||
*/
|
||||
setName(name) {
|
||||
return this.edit({ name });
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a role to the list of roles that can use this emoji.
|
||||
* @param {Role} role The role to add
|
||||
* @returns {Promise<Emoji>}
|
||||
*/
|
||||
addRestrictedRole(role) {
|
||||
return this.addRestrictedRoles([role]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add multiple roles to the list of roles that can use this emoji.
|
||||
* @param {Role[]} roles Roles to add
|
||||
* @returns {Promise<Emoji>}
|
||||
*/
|
||||
addRestrictedRoles(roles) {
|
||||
const newRoles = new Collection(this.roles);
|
||||
for (const role of roles) {
|
||||
if (this.guild.roles.has(role.id)) newRoles.set(role.id, role);
|
||||
}
|
||||
return this.edit({ roles: newRoles });
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a role from the list of roles that can use this emoji.
|
||||
* @param {Role} role The role to remove
|
||||
* @returns {Promise<Emoji>}
|
||||
*/
|
||||
removeRestrictedRole(role) {
|
||||
return this.removeRestrictedRoles([role]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove multiple roles from the list of roles that can use this emoji.
|
||||
* @param {Role[]} roles Roles to remove
|
||||
* @returns {Promise<Emoji>}
|
||||
*/
|
||||
removeRestrictedRoles(roles) {
|
||||
const newRoles = new Collection(this.roles);
|
||||
for (const role of roles) {
|
||||
if (newRoles.has(role.id)) newRoles.delete(role.id);
|
||||
}
|
||||
return this.edit({ roles: newRoles });
|
||||
}
|
||||
|
||||
/**
|
||||
* When concatenated with a string, this automatically returns the emoji mention rather than the object.
|
||||
* @returns {string}
|
||||
|
||||
Reference in New Issue
Block a user