skip to Main Content

I’m trying to create a reaction roles system for my discord server, but I’m experiencing a major issue, I’m assuming minor to most. So my bot successfully sends the embeds with the corresponding emojis for the roles, but when user reacts to the emoji the role isn’t given. Does anyone have any issue to this?

    name: 'reactionrole',
    description: "Sets up a reaction role message",
    async execute(message, args, Discord, client) {
        const channel = "971301182540771328";
        const retail = message.guild.roles.cache.find(role => role.name === "Retail");
        const consoles = message.guild.roles.cache.find(role => role.name === "Consoles");
        const gpus = message.guild.roles.cache.find(role => role.name === "GPUs");
        const footsiteRestocks = message.guild.roles.cache.find(role => role.name === "Footsite Restocks");
        const shopify = message.guild.roles.cache.find(role => role.name === "Shopify");
        const reminders = message.guild.roles.cache.find(role => role.name === "Reminders");
        const aco = message.guild.roles.cache.find(role => role.name === "ACO");
        const groupbuys = message.guild.roles.cache.find(role => role.name === "Groupbuys");
        const members = message.guild.roles.cache.find(role => role.name === "Members");
        

        const retailEmoji = '🎮';
        const consolesEmoji = '🕹ī¸';
        const gpusEmoji = '🖲ī¸';
        const footsiteRestocksEmoji = '👞';
        const shopifyEmoji = '👟';
        const remindersEmoji = '⏰';
        const acoEmoji = '📝';
        const groupbuysEmoji = '🎉';
        const memberssEmoji = '❗';

        let embed = new Discord.MessageEmbed()
        .setColor('5104DB')
        .setTitle('Select Your Roles!')
        .setThumbnail('https://cdn.discordapp.com/attachments/931332825360269333/938631314133909574/Logo_v3.png')
        .addFields(
            { name: '🎮', value: 'Retail', inline: true },
            { name: '🕹ī¸', value: 'Console Pings', inline: true },
            { name: '🖲ī¸', value: 'GPU Pings', inline: true },
            { name: '👞', value: 'Footsite Restocks', inline: true },
            { name: '👟', value: 'Shopify Pings', inline: true },
            { name: '⏰', value: 'Reminders', inline: true },
            { name: '📝', value: 'ACO Updates', inline: true },
            { name: '🎉', value: 'Groupbuys', inline: true },
            { name: '❗', value: "If you don't see any channels", inline: true },
        )
        .setFooter({ text: 'Powered by Boombap's Cookout', iconURL: 'https://cdn.discordapp.com/attachments/931332825360269333/938631314133909574/Logo_v3.png'});

        let messageEmbed = await message.channel.send({embeds: });
        messageEmbed.react(retailEmoji);
        messageEmbed.react(consolesEmoji);
        messageEmbed.react(gpusEmoji);
        messageEmbed.react(footsiteRestocksEmoji);
        messageEmbed.react(shopifyEmoji);
        messageEmbed.react(remindersEmoji);
        messageEmbed.react(acoEmoji);
        messageEmbed.react(groupbuysEmoji);
        messageEmbed.react(memberssEmoji);

        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 === retailEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.add(retail);
                }
                if (reaction.emoji.name === consolesEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.add(consoles);
                }
                if (reaction.emoji.name === gpusEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.add(gpus);
                }
                if (reaction.emoji.name === footsiteRestocksEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.add(footsiteRestocks);
                }
                if (reaction.emoji.name === shopifyEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.add(shopify);
                }
                if (reaction.emoji.name === remindersEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.add(reminders);
                }
                if (reaction.emoji.name === acoEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.add(aco);
                }
                if (reaction.emoji.name === groupbuysEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.add(groupbuys);
                }
                if (reaction.emoji.name === memberssEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.add(members);
                }
                
            } 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 === retailEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(retail);
                }
                if (reaction.emoji.name === consolesEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(consoles);
                }
                if (reaction.emoji.name === gpusEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(gpus);
                }
                if (reaction.emoji.name === footsiteRestocksEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(footsiteRestocks);
                }
                if (reaction.emoji.name === shopifyEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(shopify);
                }
                if (reaction.emoji.name === remindersEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(reminders);
                }
                if (reaction.emoji.name === acoEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(aco);
                }
                if (reaction.emoji.name === groupbuysEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(groupbuys);
                }
                if (reaction.emoji.name === memberssEmoji){
                    await reaction.message.guild.members.cache.get(user.id).roles.remove(members);
                }
            } else {
                return;
            }
        });
    }
}```

2

Answers


  1. Chosen as BEST ANSWER

    Sorry for the post, after reviewing the code, I was missing a specific intents in my index.js. The intents missing was "Intents.FLAGS.GUILD_MESSAGE_REACTIONS".


  2. You cannot use an event inside a command like that.
    Learn about collectors here: https://discordjs.guide/popular-topics/collectors.html#message-collectors

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search