Discord机器人:当某人获得角色时向其发送消息

时间:2020-08-10 17:00:50

标签: javascript discord bots

    exports.run = async (client, oldMember, newMember) => {
        const messagechannel = msg.guild.channels.find('name', 'YOUR NAME OF YOUR CHANNEL');
        if (oldMember.roles.size < newMember.roles.size) {
            const embed = new Discord.RichEmbed()
                .setColor('#FE2E2E')
                .setTimestamp()
                .setAuthor('Role added!')
                .addField(`Member:`, `${oldMember.user.tag} (${oldMember.id})`);
            for (const role of newMember.roles.map(x => x.id)) {
                if (!oldMember.roles.has(role)) {
                    embed.addField(`Role:`, `${oldMember.guild.roles.get(role).name}`);
                }
            }
            messagechannel.send({
                embed
            });
        }
    }

刚想在频道中(或私下)提及某人时,他是我的代码,但这似乎是错误的。有人可以帮我吗?

0 个答案:

没有答案