H
H
HenLeiko2022-04-21 11:50:22
JavaScript
HenLeiko, 2022-04-21 11:50:22

Why is the listener not catching reactions?

I make it possible to assign roles in response to an embed message. Everything would be fine, but awaitReaction simply does not catch the reaction on embed. I checked the documentation several times about this and still nothing works, can anyone tell me what exactly the problem could be?

if (args == 'role') {
    const roleEmbed = {
      color: '#e82c9d',
      fields: [{
          name: 'Запрос роли сотрудника',
          value: 'Нажмите реакцию',
        },
        {
          name: '\u200B',
          value: '\u200B'
        },
        {
          name: 'role one',
          value: ':one:',
        },
        {
          name: 'role two',
          value: ':two:',
        },
        {
          name: 'role three',
          value: ':three:',
        },
      ],
    };

    let rol = await message.channel.send({embeds: [roleEmbed]});
      await rol.react('1️⃣');
      await rol.react('2️⃣');
      await rol.react('3️⃣');

    const filter = (reaction, user) => {
      return ['1️⃣', '2️⃣', '3️⃣'].includes(reaction.emoji.name) && user.id === interaction.user.id;
    }    
    
    rol.awaitReactions(filter, {
      max: 1,
      time: 10000,
      errors: ['time']
    }).then(collected => {
      const reaction = collected.first();

      switch (reaction.emoji.name) {
        case '1️⃣':
          // somecode
          break;
        case '2️⃣':
          // somecode
          break;
        case '3️⃣':
          // somecode
          break;
      }
    }).catch(collected => {
      console.log('test');
    });
    setTimeout(() => {
      message.delete();
    }, 3000);
  }


Thank you in advance for your help.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question