繁体   English   中英

如何进行双向确认反应?

[英]How do I make a 2 way confirmation reaction?

我如何才能让 2 个人(我和我@的人)在确认之前必须按下检查按钮?

我的代码:

      let nine = await message.channel.send(embed)

      await nine.react('✅');
      await nine.react('❌');

      const filter1 = (reaction, user) => reaction.emoji.name === '✅' && user.id === message.author.id;
      const col1 = nine.createReactionCollector(filter1, { time: 30000, dipose: true, max: 1 });

      const filter2 = (reaction, user) => reaction.emoji.name === '❌' && user.id === message.author.id;
      const col2 = nine.createReactionCollector(filter2, { time: 30000, dipose: true, max: 1 });

      col1.on('collect', async r => {
        // the rest of my code```

这应该有效(您必须根据您的代码进行调整)

const mention = message.mentions.users.first();
const filter = (reaction, user) => [message.author.id, mention.id].includes(user.id) && reaction.emoji.name === '✅'
const reaction = await message.react('✅')
let res = false
let reactions = await message.awaitReactions(filter, {max: 2, time: 30000, errors: ['time']})
const check = reactions.mapValues(r => r.user.id)
if(check.size === 2) res = true
if(res) {
  //they both reacted
} else {
  //they didn’t both react
}

如果它不起作用告诉我发生了什么。 我没来得及测试它。

暂无
暂无

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

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