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

209
Visualizações
how to change time name every 5 minutes

I made a whatsapp bot using Baileys and made a werewolf game feature, I want the time to change every 5 minutes from morning to night then morning again like a loop until the winner is determined. I use setInterval but it causes spam

I also used Node Corn and the result is the same

the all_room json db

[
{
"code":"FJ32Q",
"group_id":"6288742689173-1610938001@g.us",
"time":"morning",
"night":0,
"status":"starting",
"vote":false
}
]

getTime (function to get time from db)

const getTime = (group) => {
let alldb = JSON.parse(fs.readFileSync('./database/ww/all_room.json'))
satu = alldb.find((obj => obj.group_id == `${group}`));
return satu.time
}

set_time (functon to change value)

const set_time = (times, group) => { 
let alldb = JSON.parse(fs.readFileSync('./database/ww/all_room.json'))
satu = alldb.findIndex((obj => obj.group_id == `${group}`));
alldb[satu].time = times
fs.writeFileSync('./database/ww/all_room.json', JSON.stringify(alldb))
}

if(isWS(group.id)){ // true
  setInterval(() => {
    if(getTime() === "morning") { 
      set_time("night")
      reply("the sun is setting be careful because the werewolves are starting to roam")
    } else if(getTime() === "night") {
      set_time("morning")
      reply("the sun has risen")
    }
  }, 300000);
}




Result

this is even spam

result

about 4 years ago · Juan Pablo Isaza
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