Discord bot验证系统

时间:2020-09-16 15:52:27

标签: javascript discord.js

const Discord = require('discord.js');
module.exports = {
 name: 'verify',
 execute(message, args) {
  const embed3 = new Discord.MessageEmbed()
   .setTitle('Verify')
   //.setColor(0xff0000)
   .setColor('9400D3')
   .setDescription('Click on the ✅ to acess the server!');
  //.setFooter('Coded by GalaxyBoy#9353,Iron#0447 and blackout#8324')

  message.channel.send(embed3).then((sentEmbed) => {
   sentEmbed.react('✅');

   const filter = (reaction, user) => {
    return (
     ['✅'].includes(reaction.emoji.name) && user.id === message.author.id
    );
   };

   sentEmbed
    .awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
    .then((collected) => {
     const reaction = collected.first();

     if (reaction.emoji.name === '✅') {
      message.reply('This part is working.');
     }
    })
    .catch((collected) => {
     message.reply('you reacted with neither a thumbs up, nor a thumbs down.');
    });
   `enter code here`;
  });
 },
};

我该如何修改此代码,以使其发挥作用,而不仅仅是说它在起作用?我尝试做几件事情,但似乎没有任何效果,相反,我所做的一切都直接被抓住了。有人有解决此问题的解决方案吗?如果是这样,将不胜感激。

1 个答案:

答案 0 :(得分:0)

您可以使用GuildMemberRoleManager.add()

if (reaction.emoji.name === '✅') {
 message.member.roles.add('Role ID');
}