mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53:31 +01:00
feat: throw custom error for uncached Guild#me (#3271)
* handle cases where Guild#me is uncached * fix id prop * remove unnecessary checks * space's requested changes
This commit is contained in:
@@ -60,6 +60,7 @@ class GuildEmoji extends Emoji {
|
||||
* @readonly
|
||||
*/
|
||||
get deletable() {
|
||||
if (!this.guild.me) throw new Error('GUILD_UNCACHED_ME');
|
||||
return !this.managed &&
|
||||
this.guild.me.hasPermission(Permissions.FLAGS.MANAGE_EMOJIS);
|
||||
}
|
||||
@@ -80,8 +81,11 @@ class GuildEmoji extends Emoji {
|
||||
fetchAuthor() {
|
||||
if (this.managed) {
|
||||
return Promise.reject(new Error('EMOJI_MANAGED'));
|
||||
} else if (!this.guild.me.permissions.has(Permissions.FLAGS.MANAGE_EMOJIS)) {
|
||||
return Promise.reject(new Error('MISSING_MANAGE_EMOJIS_PERMISSION', this.guild));
|
||||
} else {
|
||||
if (!this.guild.me) return Promise.reject(new Error('GUILD_UNCACHED_ME'));
|
||||
if (!this.guild.me.permissions.has(Permissions.FLAGS.MANAGE_EMOJIS)) {
|
||||
return Promise.reject(new Error('MISSING_MANAGE_EMOJIS_PERMISSION', this.guild));
|
||||
}
|
||||
}
|
||||
return this.client.api.guilds(this.guild.id).emojis(this.id).get()
|
||||
.then(emoji => this.client.users.add(emoji.user));
|
||||
|
||||
Reference in New Issue
Block a user