Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
How can I access collected reaction from awaitReactions?

This is my code and I want to access the collected emojis and send them back as a reply. I am also inserting the object I am getting from collected.

Here is the link for the object data: https://pastebin.com/MDm9dsvD

const emojis = [
  'booknquill',
  'balloon1',
  'rail',
  'Alex',
  'cookie1',
  'fish1',
  'Agent',
  'cake1',
  'pickaxe',
  'water',
  'Steve',
  'Apple',
  'carro1t',
  'panda',
  'sign',
  'potion',
  'map1',
  'llama1',
];

let msg = await message.channel.send('`What is your Code ?....`');

for (let i = 0; i < emojis.length; i++) {
  let reactionEmoji = message.guild.emojis.cache.find(
    (emoji) => emoji.name === emojis[i],
  );
  msg.react(reactionEmoji);
}

let reactedEmojis = [];

for (let i = 0; i < emojis.length; i++) {
  reactedEmojis.push(
    message.guild.emojis.cache.find((emoji) => emoji.name === emojis[i]),
  );
}

const filter = (reaction, user) => {
  return !user.bot;
};

msg
  .awaitReactions({ filter, max: 4, time: 60000, errors: ['time'] })
  .then((collected) => {
    console.log(collected.size);
    let userReaction = collected[0];
    console.log(collected[0]);
    message.channel.send(userReaction._emoji.name);
  });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

collected is a collection, not an array, so you can't simply access the first item using [0]. You can use methods like .first(), .last(), .at(), etc to access items.

To get the first collected item, you can use let userReaction = collected.first() or let userReaction = collected.at(0).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!