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

373
Vistas
Discord.js use try catch statement to handle api error

Hello I am currently attempting to catch a discord api error with the try catch statement

However for some reason this does not work and my app still stops executing and gives me the following message

 There was an uncaught error DiscordAPIError: Cannot send messages to this user // Example

How do I catch api errors with a try and catch block and I cannot use a .catch expression after calling the function

Here is my code

try {
    interaction.user.send("Remember")
}
catch(DiscordAPIError) {
    console.log("Oh no")
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you want to use a synchronous try/catch block, you need to put it in an async function and await the promise from interaction.user.send:

await interaction.user.send("Remember")
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