[英]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');
const Discord = require('discord.js');
module.exports = {
name: 'reactionrole',
async execute(message, args, client) {
const channel = client.channels.cache.get('911914917295161354');
const emojireact = '👍';
let embed = new MessageEmbed()
.setColor('#e42643')
.setTitle('Title')
.setDescription('description')
if(message.member.roles.cache.some(r => r.name === "Admin" || r.name === "Badmin" || r.name === "Owner")){
channel.send({ embeds: [embed]}).then(msg => msg.react(emojireact));
}
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 === emojireact) {
await reaction.message.guild.members.cache.get(user.id).roles.add(Members);
}
}else {
return;
}
});
}
};
The command shows the embed and the bot reacts but the user isn't added.该命令显示嵌入,机器人做出反应,但未添加用户。
Not sure how are you not getting a ReferenceError
but you are passing an unknown variable to the parameter.不确定您如何没有收到ReferenceError
但您将未知变量传递给参数。
At .add(Members)
, I don't see Members
defined anywhere in the code you sent.在.add(Members)
,我看不到您发送的代码中任何地方定义的Members
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.