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

208
Views
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
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!