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

293
Vistas
Should I use setTimeout() in production with discord.js?

I'm working on a bot and I want to set state of a button from enable to disabled.

here, I'm confused as if I should use setTimeout() to disable button after 20 seconds or leave it as it is. As setTimeout() is called everytime when user uses "!purchases" command.

setTimeout(() => {
    row.components[0].setDisabled(true);
    row.components[1].setDisabled(true);
    row.components[2].setDisabled(true);
    sentMessage.edit({
        content: 'You cannot interact with buttons now!',
        components: [row],
    });
}, 20000);

After what I've searched on google I've found that setTimeout() works in a async manner which mean if I've process1 as my main discord bots reply, process2, process3 and process4 are setTimeout() then node.js will not execute all these operations in parallel instead it will execute process1 if process2 is fetching or sending data, and vice versa.

Q0) is what I've found incorrect or has information missing?

Q1) So is it recommended in this scenario to use setTimeout()?

Q2) Will setTimeout() compound over the time or not?

Q3 Will there be any perfomence issue due to setTimeout()

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think you found some good information, but you may not fully understand it.

About asynchronous nature of setTimeout() from MDN

setTimeout() is an asynchronous function, meaning that the timer function will not pause execution of other functions in the functions stack. In other words, you cannot use setTimeout() to create a "pause" before the next function in the function stack fires.

So your setTimeout() should not block other functions.

Answering to other questions:

I think that use of setTimeout() here is correct.

The setTimeout should not compound over time - each setTimeout gets a unique timeoutID and it is returned as positive integer value of setTimeout() function.

There should not be performence issues.

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