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

90
Vistas
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 Respuestas
Responde la pregunta

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