Can't React with Unicode Emojis discord.js

Viewed 816

I'm throwing together a poll command for my discord bot, and need emojis as options. However, when I try to react with default emojis I got from the message, it fails. I won't get into too many specifics, but here is almost all the relevant code:

    // This just takes the <prefix> poll off then splits it by newlines
    const args = message.content.slice(message.content.indexOf("poll")+"poll ".length).split("\n");

    const fields = [];
    const reactions = [];

    // First arg is title
    for(let i = 1; i < args.length; i++){
        const splits = args[i].split("-"); // Split each arg by -
        fields.push(splits[0] + ":   " + splits[1]); // Field title
        fields.push(splits[2]); // Field description

        reactions.push(splits[0]); // This should be an emoji
    }


    // This function takes in message, embed title, [field title, field description, ...]
    const msg = await embedGenerator.sendNormalEmbed(message, args[0], "", fields);

    // React
    for(let i = 0; i < reactions.length; i++){
        await msg.react(reactions[i])
    }

This works perfectly fine with custom emojis, however, it fails with default Unicode emojis: enter image description here

The second poll gives me this error: enter image description here

After some looking the put request makes a call that should react, however, the ID of the emoji is the Unicode code for . Is there any way to get a normal emoji instead of this Unicode code from the text, and if not is there a way to force discord to react with the Unicode code?

1 Answers

I was bit confused in your question, So maybe I am not correct. if it is, so please comment and ping me. You can also ask me for other help.

  • Reason:-

So discord does not use id for reacting of default emojis which are already in discord. If you want to implement ":helicopter:" as reaction, You need to replace it with this "".

  • Solution:-

You can still solve it by telling user to insert "\" before ":helicopter:" so that emoji becomes unicode or there's an npm package for that, this.

Also you can refer to this site to copy and paste them or this for help on emojis.

Related