Custom emoji reaction role

Viewed 182

The reaction button works fine but the only problem it shows the ID of the custom emoji in embed message.

enter image description here

Here is the code:

{name: 'reactionrole',
    description: "Sets up a reaction role message!",
    async execute(message, args, Discord, client) {
        const channel = '866637673937895457';
        const redTeamRole = message.guild.roles.cache.find(role => role.name === "Red");
        const yellowTeamRole = message.guild.roles.cache.find(role => role.name === "Yellow");
        const RandomTeamRole = message.guild.roles.cache.find(role => role.name === "olddrawinlmaooo");
 
        const redTeamEmoji = '';
        const yellowTeamEmoji = '';
        const RandomTeamEmoji = '889108655344091156';
        

 
        let embed = new Discord.MessageEmbed()
            .setColor('#e42643')
            .setTitle('Choose a team to play on!')
            .setDescription('Choosing a team will allow you to interact with your teammates!\n\n'
                + `${redTeamEmoji} for yellow team\n`
                + `${yellowTeamEmoji} for blue team\n`
                + `${RandomTeamEmoji} for random team`);
 
        let messageEmbed = await message.channel.send(embed);
        messageEmbed.react(redTeamEmoji);
        messageEmbed.react(yellowTeamEmoji);
        messageEmbed.react(RandomTeamEmoji);
 
        client.on('messageReactionAdd', async (reaction, user) => {
            if (reaction.message.partial) await reaction.message.fetch();
            if (reaction.partial) await reaction.fetch();
            if (user.bot) return;
            if (!reaction.message.guild) return;
 
            if (reaction.message.channel.id == channel) {
                if (reaction.emoji.name === redTeamEmoji) {
                    await reaction.message.guild.members.cache.get(user.id).roles.add(redTeamRole);
                }
                if (reaction.emoji.name === yellowTeamEmoji) {
                    await reaction.message.guild.members.cache.get(user.id).roles.add(yellowTeamRole);
                }
                if (reaction.emoji.name === RandomTeamEmoji) {
                    await reaction.message.guild.members.cache.get(user.id).roles.add(RandomTeamRole);
                }
            } else {
                return;
            }
 
        });
 
        client.on('messageReactionRemove', async (reaction, user) => {
 
            if (reaction.message.partial) await reaction.message.fetch();
            if (reaction.partial) await reaction.fetch();
            if (user.bot) return;
            if (!reaction.message.guild) return;
 
 
            if (reaction.message.channel.id == channel) {
                if (reaction.emoji.name === redTeamEmoji) {
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(redTeamRole);
                }
                if (reaction.emoji.name === yellowTeamEmoji) {
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(yellowTeamRole);
                }
                if (reaction.emoji.name === RandomTeamEmoji) {
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(RandomTeamRole);
                }
            } else {
                return;
            }
 
        });

    }

}  }
2 Answers

Replace the ID with the emoji name AND the ID. It'll look something like this:

<:yeah:735918408561852457>

To get that easily, just put a \ in front of the emoji you want, and then send it in a channel, it'll give you that format.

const RandomTeamEmoji = '<:nameofemoji:889108655344091156>';

Instead of

const RandomTeamEmoji = '889108655344091156';
Related