Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
Filter out emojis from the list which the bot cannot display
Browse files Browse the repository at this point in the history
  • Loading branch information
ShawnCZek committed Jul 10, 2020
1 parent 3333a5a commit 955aab4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/managers/emoji.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class EmojiManager {
static generateList(guild: Guild): string[] {
const entries: string[] = [];

const emojis = guild.emojis.cache.sort(this.sortEmojis);
const emojis = guild.emojis.cache.filter(this.filterEmojis).sort(this.sortEmojis);
for (const [, emoji] of emojis) {
entries.push(`${emoji} \`:${emoji.name}:\``);
}
Expand Down Expand Up @@ -58,6 +58,15 @@ export class EmojiManager {
return <TextChannel>channel;
}

/**
* Filter emojis so the bot can display them.
*
* @param emoji
*/
protected static filterEmojis(emoji: GuildEmoji): boolean {
return !emoji.managed;
}

/**
* Sort emojis by their name in the ascending order.
*
Expand Down

0 comments on commit 955aab4

Please sign in to comment.