Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda