Discord.js DiscordAPI Error: Unknown Emoji - Reacting to an Embed

Viewed 1213

Here's my code:

client.on('message', message => {
    if (message.content.startsWith("!embed")) {
        const embed = new Discord.MessageEmbed()
            .setColor(0xffffff)
            .setFooter(`Page 1`)

        message.channel.send(':rewind::fast_forward:'); //this works

        //but this doesn't
        message.channel.send(embed).then(embedMessage => {
            embedMessage.react(":rewind:");
        });
});

I may have a hidden issue or not provided the correct parameters. I have looked at a similar previously asked question and tried implementing it, but it didn't work, may be outdated.

Instead, I receive an error:

UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Emoji

The emoji I'm using is provided in the standard emoji library, :rewind:

2 Answers

you have to use unicode emojis instead, Here is an example:

embedMessage.react("⏪");

Discord.Js does not handle emojis with the Discord User Side :rewind: stuff. Discord.js is using unicode to send and receive emojis, except for custom emojis, IDs are used there instead.

This means that you should use the following code instead.

embedMessage.react("⏪");

The Unicode emojis can be found by "escaping" the emoji in Discord or using something like: https://getemoji.com/.

The escaping works by using \ in front of the emoji, you might know this from \n. By putting \:rewind: the result will look as follows.

Normal and Escaped Emoji

When copying the Unicode emoji make sure to delete any spaces off of it.

Related