Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!