簡體   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