Discord.js忽略其他表情符号

Discord.js忽略其他表情符号,discord.js,emoji,Discord.js,Emoji,我正在做一个功能反应角色机器人。我试图找出如何添加一个过滤器,忽略我分配的表情以外的其他表情。机器人工作正常,除非我或其他人试图用我指定的表情以外的表情与机器人做出反应 client.on('message', message => { if(message.author.bot || message.embeds) embedMsg = message.embeds.find(msg => msg.title === 'Server Roles') ? mess

我正在做一个功能反应角色机器人。我试图找出如何添加一个过滤器,忽略我分配的表情以外的其他表情。机器人工作正常,除非我或其他人试图用我指定的表情以外的表情与机器人做出反应

client.on('message', message => {

    if(message.author.bot || message.embeds)

    embedMsg = message.embeds.find(msg => msg.title === 'Server Roles') ? message : undefined
      if(embedMsg) 
      {

      embedMsg.react('755602275963109536')
            .then
(reaction => reaction.message.react('755604749814071366'))
            .then(reaction => reaction.message.react('755605241067601960'))
            .then(reaction => reaction.message.react('755604978571280466'))
            .then(reaction => reaction.message.react('755604795292909589'))
            .then(reaction => reaction.message.react('755605048666620075'))
            .then(reaction => reaction.message.react('755604953229164594'))
            .then(reaction => reaction.message.react('755604994656436346'))
            .then(reaction => reaction.message.react('755605995195072603'))
            .then(reaction => reaction.message.react('755605032124022814'))
            .then(reaction => reaction.message.delete(20000))
            .then(msg => console.log("Deleted message"))
            .catch(() => console.error('One of the emojis failed to react.'));
            return;
      }

client.on('messageReactionAdd', (reaction, user) => {
    if (user.bot) return;
   
    var roleName = reaction.emoji.name;
    console.log(roleName);
    var role = reaction.message.guild.roles.find(
     role => role.name.toLowerCase() === roleName.toLowerCase()
    );
    var member = reaction.message.guild.members.find(
     (member) => member.id === user.id
    );
   //remove role
    if (member.roles.has(role.id)) {
     member
      .removeRole(role.id)
      .then((member) => {
       console.log(
        'Removed' + member.user.username + ' from the ' + role.name + ' role.'
       );
      })
      .catch((err) => console.error);
    //add role  
    } else {
     member
      .addRole(role.id)
      .then((member) => {
       console.log(
        'Added ' + member.user.username + ' to the ' + role.name + ' role.'
       );
      })
      .catch((err) => console.error);
    }
   });

您可以创建一个已接受表情符号的数组,并根据给定的反应测试每个表情符号

const数组=['ID#1','ID#2','ID#3','等等];
如果(!array.includes(reaction.emoji.id))返回;