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

185
Vistas
Run a script before Command Prompt stops

I have a Discord Bot that edits a message every second. So if the bot goes off, the message will display the last edit.

I would like to, before closing the Node JS process (using Ctrl + C, closing the Command Prompt or any type of closing the process), edit the message to say something like: "The bot is off".

Example:

// something using discord.js
bot.on("close", myFunction);

// or in node, like in browser 'window.onbeforeunload'
node.beforecloseprocess = myFunction;

If theres a way with discord.js, that would be cool and resolve my problem, but if there a way of using Node Js it self or something in the Command Prompt would be better for future projects aside discord.js.

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

0

I would use the discord.js event 'close' and call a function that would change the message to 'The bot is off'.

also:

process.on('SIGINT', function() {
  console.log("Closing")
}
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