Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda