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

120
Visualizações
Count time between messages with discord.js and replit database

I've been googling for a long time now and can't find a solution. My current code:

let end = new Date().getTime();
if(Msg == "test") {
  // ...
}
db.set("start", new Date().getTime());

If I try to send db.get("start") it will send

[object Promise]

If I try to send db.get("start") - end it will send

NaN

I wanna measure the time between previous message and last one(that was just sent) so my solution for it is using the data base to keep the time when the last one was sent. This worked back when I coded a bot in python but now in JavaScript I can't get it to work.

Can anyone please help?

p.s Msg = msg.content. Not that important but whatever

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

db.get() returns a promise, which you need to await

const start = await db.get("start")
console.log(start - end)
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