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

156
Views
DiscordJS V12 Reactions not Catching Error
    channel.send(embed).then(m => {
      m.react("<:check:947079937372872704>")
      m.react("<:warning:943421375526355024>")
    }).catch(err => {
      message.channel.send('Error')
    })

This is my code but when the bot doesn't have add reaction perms it crashes instead of catching it and printing Error

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The problem is that you have two promises inside your then block that don't return anything as a whole. This means that your catch block won't catch anything because there is nothing to catch.

If you remove one of the reactions and tweak it a bit then it will work as expected.

.then((m) => m.react("✅"))

Note that this implicitly returns the promise created by m.react("✅"), which can then conditionally be caught by your catch block.

So the natural question is how do you add these reactions while still keeping the structure?

One solution is to use Promise.all()

.then((m) => Promise.all([m.react("✅"), m.react("⚠️")]))

In short, it takes an array of promises and attempts to resolve them. If all goes well it returns an array of the resolved values. If there is an error it will return the first error it encounters.

Hope this helped!

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!