繁体   English   中英

我正在尝试在对嵌入做出反应时将用户添加到角色中并且不会添加它们

[英]I'm trying to add a user to a role when reacting to an embed and won't add them

我在使用嵌入时发出命令,机器人对其作出反应,当其他人对其作出反应时,它会将它们添加到规则中。 但它没有将用户添加到角色中,我不确定为什么。

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;
            }
        });
            
    }
};

该命令显示嵌入,机器人做出反应,但未添加用户。

不确定您如何没有收到ReferenceError但您将未知变量传递给参数。
.add(Members) ,我看不到您发送的代码中任何地方定义的Members

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM