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

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

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