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

89
Views
Added execution time in discord.js bot console

I created a discord.js bot that works all the time. In the terminal where the bot is running I would like the running time of the bot since it started up to be displayed below "I am connected !".

Here is part of my console code :

client.on('ready', () => {
      console.log('I am connected !');

Do you have any ideas ?

Thank you in advance for your help.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As suggested by @Lawrence Cherone, you can use a date in the top of the file to compare with one on ready. For example:

const startup = new Date()
// Other code...

client.on("ready" => {
  const ready = new Date()
  const diff = ready.getTime() - startup.getTime()
  console.log(`I am connected! Startup took ${diff}ms`)
})

If you want the time in a format other than milliseconds, you can use ms, a tiny library written by Vercel devs on npm which converts milliseconds into human-friendly timestamps.

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!