ทำไมไม่นับ reactions

0

คำถาม

เป้าหมายของฉันนี่คือการนับ reactions แต่เมื่อฉันมีปฏิกิริยาอยู่กับปฎิกิริยาได้ไวขนาดที่ bot ไม่นับได้แล้วถ้าคนสองคนมีปฏิกิริยาฉันจะไม่ให้ทั้งสองคน reactions.

collector.on('end', (collected) => {
  let i = 0;

  const collectedembed = new Discord.MessageEmbed();

  collected.forEach((value) => {
    i++;

    collectedembed.setTitle(question);
    if (i === 1) {
      collectedembed.addField('1st option', value.content);
    } else if (i === 2) {
      collectedembed.addField('2nd option', value.content);
    }
  });

  message.channel.send({ embeds: [collectedembed] }).then((poll) => {
    poll.react('1️⃣');
    poll.react('2️⃣');

    const filter2 = (reaction, user) => {
      return ['1️⃣', '2️⃣'].includes(reaction.emoji.name) && user.id === message.author.id;
    };

    const collector2 = poll.createReactionCollector({ filter: filter2, time: 5000 });

    collector2.on('end', (collected) => {
      poll.channel.send(
        `reacted with 1️⃣ ${poll.reactions.cache.get('1️⃣').count} users \n reacted with 2️⃣${
          poll.reactions.cache.get('2️⃣').count
        } users`,
      );
    });
  });
});

นี่คือภาพตัวอย่างของปัญหาของฉั:

enter image description here

discord discord.js javascript
2021-11-23 10:30:15
1

คำตอบที่ดีที่สุด

0

คุณควรจะนับจำนวนเงินโดบประมาณของแต่ละค reactions ถูกเซ็นกำกับโดยใช้ <Collection> พารามิเตอร์ของ <ReactionCollector>.on('end', ...) วิธีการขอเรียกกลับการตรวจสอบสิทธิ์

collector2.on('end', collected => {
    poll.channel.send(collected.map(reaction => `${reaction.emoji} » ${reaction.count} Users`).join('\n'));
});
2021-11-23 11:22:42

yeap พวกผู้ชมน่ะได้ยินพวกเธอทำงาน tahnks!
Navid

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่