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

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

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 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