Soulless Rekkr
Soulless Rekkr

Reputation: 125

Discord Bot Reads Emoji To Assign Roles

Okay I got the emoji to work finally thanks to ~slothiful~.

I am not attempting to have the bot assign a role based on the reaction to a message that is posted as the rules of the server.

bot.on('message', (message) => {
        if (message.content == ':joy:' ) {
                message.member.roles.add(Yard);
        }
});

Thanks for the Answer

Upvotes: 1

Views: 847

Answers (1)

slothiful
slothiful

Reputation: 5623

You must use the Unicode versions of the emojis, because that's what the templates are converted to. This means that what you typed as :joy: is actually 😂 in message.content.

To get the Unicode character(s) from any emoji in Discord, send \:joy:, for example, and copy the resulting message. Just for further clarification, in both cases, :joy: and \:joy:, message.content will read 😂.

Take a look at this guide for more info about how emojis work and collecting reactions.

Upvotes: 2

Related Questions