简体   繁体   English

Discordjs 我的反应收集器在我不希望它触发时触发

[英]Discordjs my reaction collector is triggering when I don't want it to

I have a snippet of code here我这里有一段代码

      const filter2 = (reaction, user) => {
        return reaction.emoji.name === '👎' && user.id === message.author.id;
      };

      const collector = confirmedMessage.createReactionCollector({filter2, time: 50000});
      collector.on('collect', (reaction, user) => {
        console.log("PLEASE");
      });

在此处输入图像描述

The collector will trigger regardless of whether I react to thumbs up or thumbs down.无论我对竖起大拇指还是不竖起大拇指做出反应,收集器都会触发。 May I know why is it happening?我可以知道为什么会这样吗? Thanks!谢谢!

It's because you don't use the filter option .这是因为你没有使用filter选项 When you simply pass an object like { filter2 } , you're actually saying { filter2: filter2 } , so there is no filter key, just filter2 .当您简单地传递 object 时,例如{ filter2 } ,您实际上是在说{ filter2: filter2 } ,因此没有filter键,只有filter2

Try to change your options like this:尝试像这样更改您的选项:

createReactionCollector({ filter: filter2, time: 50000 })

OR rename const filter2 = to const filter = .或者将const filter2 =重命名为const filter =

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

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