buddyswift
cron not running as scheduled
let lastRunDate = null;
client.once('ready', () => {
console.log('Bot is ready!');
setInterval(checkAndRun, 60 * 1000); // Check every minute
});
client.login(BOT_TOKEN);
async function checkAndRun() {
const now = new Date();
const ninePM = new Date(now);
ninePM.setUTCHours(21, 0, 0, 0); // Set to 9pm UTC
if (now > ninePM && (!lastRunDate || lastRunDate.getDate() !== now.getDate())) {
lastRunDate = now;
await fetchAndPost();
}
}
44 replies