feat(GuildEmoji): add deletable getter (#2535)

* feat(GuildEmoji#deletable)

* Update: Discord API returns 50001

When you try to get or delete a managed emoji from the API, you get a 50001 (Missing Access) error code.
This commit is contained in:
Kyra
2018-05-06 21:12:16 +02:00
committed by SpaceEEC
parent 90312952d9
commit fca6d3be56

View File

@@ -1,4 +1,5 @@
const GuildEmojiRoleStore = require('../stores/GuildEmojiRoleStore');
const Permissions = require('../util/Permissions');
const Snowflake = require('../util/Snowflake');
const Emoji = require('./Emoji');
@@ -44,9 +45,20 @@ class GuildEmoji extends Emoji {
return clone;
}
/**
* Whether the emoji is deletable by the client user
* @type {boolean}
* @readonly
*/
get deletable() {
return !this.managed &&
this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_EMOJIS);
}
/**
* A collection of roles this emoji is active for (empty if all), mapped by role ID
* @type {GuildEmojiRoleStore<Snowflake, Role>}
* @readonly
*/
get roles() {
return new GuildEmojiRoleStore(this);