【问题标题】:Get roles from reaction从反应中获取角色
【发布时间】:2021-04-07 21:09:25
【问题描述】:

我正在尝试为我的机器人创建带有反应的消息,如果用户单击特定反应,他会自动获得我通过代码选择的角色。我不明白我所做的问题出在哪里。

        await msg.react('????');
          if (reaction.emoji.name === '????') {
            if (reaction.message.channel.id === "793239655331004448");
            let role = reaction.guild.roles.cache.find(role => role.id === '689880327782400203');
            member.roles.add(role.id);
            console.log('Ruolo Aggiunto'); //role added
          } else {
            console.log("Errore"); //Error
          }```

【问题讨论】:

    标签: discord discord.js bots roles


    【解决方案1】:
    await msg.react('?');
              if (reaction.emoji.name === '?') {
                if (reaction.message.channel.id === "793239655331004448");
                console.log('lol');
                let role = reaction.guild.roles.cache.find(role => role.id === '689880327782400203');
                console.log('lol');
                member.roles.add(role);
                console.log('Ruolo Aggiunto'); //role added
              } else {
                console.log("Errore"); //Error
              }```
    

    【讨论】:

      猜你喜欢
      • 2021-03-16
      • 2015-07-07
      • 2020-11-24
      • 2011-07-04
      • 2021-09-30
      • 2021-02-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多