pragmatrick
pragmatrick

Reputation: 645

GuildEmojis and UnicodeEmojis are not working well together

I am searching for something that unicode emojis and custom emojis have in common together. Lets say I have a JSON file

{
     "emojis": ["something1", "something2", "something3"]
}

My discord.js bot should now compare lets say a messageReactionAdd-event's emoji to the elements of this array. Lets say if the emoji matches one of the somethings, console.log("trigger") should happen. However the code is not important. I can't find anything I can compare what both Custom Emojis and Unicode Emojis have in common. Like a custom emoji has an ID, a unicode doesn't, therefore it has an "picture", like 😁, a custom emoji doesn't. Does someone has an idea?

Thanks in advance!

Upvotes: 0

Views: 206

Answers (1)

Daemon Beast
Daemon Beast

Reputation: 2909

Why not store both unicode emojis and custom emoji IDs?

emojis.json

{
  "emojis": ["😀", "👍", "🎉", "396548322053062656", "266241948824764416"];
}

bot.js

const emojis = require('emojis.json').emojis;

client.on('messageReactionAdd', (reaction, user) => {
  if (emojis.includes(reaction.emoji.name) || emojis.includes(reaction.emoji.id)) {
    console.log('Found emoji.');
  } else {
    console.log('Could not find emoji.');
  }
});

Upvotes: 2

Related Questions