mirror of
https://github.com/danbulant/discord.js
synced 2026-06-18 14:11:09 +00:00
GuildEmoji.fetchAuthor() error handling (#2788)
* handle when client has insufficient permissions, add typing * code review
This commit is contained in:
parent
be4d6f9dc3
commit
314161ab70
3 changed files with 5 additions and 0 deletions
|
|
@ -95,6 +95,8 @@ const Messages = {
|
|||
|
||||
EMOJI_TYPE: 'Emoji must be a string or GuildEmoji/ReactionEmoji',
|
||||
EMOJI_MANAGED: 'Emoji is managed and has no Author.',
|
||||
MISSING_MANAGE_EMOJIS_PERMISSION:
|
||||
guild => `Client must have Manage Emoji permission in guild ${guild} to see emoji authors.`,
|
||||
|
||||
REACTION_RESOLVE_USER: 'Couldn\'t resolve the user ID to remove from the reaction.',
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,8 @@ 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));
|
||||
}
|
||||
return this.client.api.guilds(this.guild.id).emojis(this.id).get()
|
||||
.then(emoji => this.client.users.add(emoji.user));
|
||||
|
|
|
|||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
|
|
@ -545,6 +545,7 @@ declare module 'discord.js' {
|
|||
public delete(reason?: string): Promise<GuildEmoji>;
|
||||
public edit(data: GuildEmojiEditData, reason?: string): Promise<GuildEmoji>;
|
||||
public equals(other: GuildEmoji | object): boolean;
|
||||
public fetchAuthor(): Promise<User>;
|
||||
public setName(name: string, reason?: string): Promise<GuildEmoji>;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue