I want to run my discord.js bot in specific hours of a day like between 6:00 AM to 1:00 PM and then rest for 2 hours and start again from 3:00 PM to 10:00 PM rest again for 2 hours and then 12:00 midnight to 6:00 AM?
Yes you can do this.
import { Client } from "discord.js";
const app = client
let doStuf = true
setInterval(async () => {
doStuf = !doStuf
if(doStuf) {
app.login(token)
} else {
app.destory()
}
}, 10000)
With this code, your bot is every 10s on and off. You can change the doStuf with a time function. That returns if at this time de bot needs to be offline or online.