From fca6d3be568fa57fb75bb3483ac6d637d5a4e190 Mon Sep 17 00:00:00 2001 From: Kyra Date: Sun, 6 May 2018 21:12:16 +0200 Subject: [PATCH] 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. --- src/structures/GuildEmoji.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/structures/GuildEmoji.js b/src/structures/GuildEmoji.js index c976eb780..95d970e04 100644 --- a/src/structures/GuildEmoji.js +++ b/src/structures/GuildEmoji.js @@ -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} + * @readonly */ get roles() { return new GuildEmojiRoleStore(this);