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.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment