Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
I'm trying to add a user to a role when reacting to an embed and won't add them

I made a command when using an embed the bot reacts to it and when anyone else reacts to it, it will add them to a rule. But it isn't adding the user to the role and I'm unsure why.

    const {MessageEmbed} = require("discord.js");

module.exports = {
  name: "reactionrole",
  async execute(message, args, client) {
    const channel = '914676864004554803';
    const memberRole = message.guild.roles.cache.find(role => role.name === "Members");

    const emojireact = '๐Ÿ‘';

    let embed = new MessageEmbed()
      .setColor("#e42643")
      .setTitle("MineCraft Server Rules")
      .setDescription(
        "To keep our server safe we need a few basic rules for everyone to follow!"
      )
      .setFooter("Please press ๐Ÿ‘ to verify and unlock the rest of the server!")

    let messageEmbed = await message.channel.send({ embeds: [embed] });
    messageEmbed.react(emojireact);
    
    client.on('messageReactionAdd', async(reaction, user, GUILD_MESSAGES_REACTIONS) => {
      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 === emojireact) {
          await reaction.message.guild.members.cache.get(user.id).roles.add(memberRole);
        }
      }else {
        return;
      }
    });

  }
}

The command shows the embed and the bot reacts but the user isn't added.

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

Not sure how are you not getting a ReferenceError but you are passing an unknown variable to the parameter.
At .add(Members), I don't see Members defined anywhere in the code you sent.

about 4 years ago ยท Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!