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

138
Views
Why isn't the catch statement working for emoji reactions? | discord.js v13

So i'm trying to edit an embed when the user doesn't react with something like gameover you lost @user! only issue is, it's not editing at all and it's not even entering the catch statement it just keeps going into the then statement. I've done this method before and I'm currently using it for another command and works 100% correctly and I've just copied the code as is and still doesn't work and I don't understand why.

const testEmbed = new discord.MessageEmbed()
  .setColor('#FFFFFF')
  .setTitle("Test")
  .setDescription(`${message.author} was here!`)
  .addFields({
    name: `${message.author}`,
    value: `The name of the author`,
    inline: true
  }, {
    name: `${message.author.id}`,
    value: `The ID of the author`,
    inline: true
  })
  .setImage(`some link to some image`)

const reactEmbed = await message.channel.send({
  embeds: [testEmbed]
});
await reactEmbed.react("๐Ÿคœ");
await reactEmbed.react("๐Ÿค›");

const filter = (reaction, user) => {
  return ["๐Ÿคœ", "๐Ÿค›"].includes(reaction.emoji.name) && user.id === message.author.id;
}


reactEmbed.awaitReactions({
    filter,
    max: 1,
    time: 15000,
    error: ["time"]
  }).then(
    async(collected) => {
      const reaction = collected.first();
      console.log(`${reaction} i am in the then statement`);
    })
  .catch(async collected => {
    console.log(`${collected} im in the catch statement`)
    reactEmbed.reactions.removeAll();
    const reactEmbedEdited = new discord.MessageEmbed()
      .setTitle(`Gameover!`)
      .setColor('#000000')
      .addField('new Field', 'new Field')
    await reactEmbed.edit({
      embeds: [reactEmbedEdited]
    });
  })

The output expected would be for the original embed sent to be edited into the new embed if no one reacts. However, when i test this command by running it, it sends the original embed, reacts then waits 15 seconds and prints the first statement i am in the then statement which completely makes no sense judging that it works perfectly fine in my other command and comparing them both there is no difference between them. So my questions are:

  1. Why does it enter the then statement?
  2. Why won't it enter the catch statement?
  3. What is the issue with it and how can it be fixed?

I'm getting no errors just the console log output.

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

You are missing an s in errors so:

reactEmbed.awaitReactions({
    filter,
    max: 1,
    time: 15000,
    errors: ["time"]
         ^
  }).then(...)
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!