buddyswift
buddyswift
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
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
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
implemented this in my code, seems to work great after removing the external cron
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
ok brody, thank you
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
or should i just go back to the drawing board and figure out continuous running of the bot
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
client.once('ready', async () => { console.log('Bot is ready!'); await fetchAndPost(); client.destroy(); process.exit(0); }); would this work better?
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
well i didnt 'exit' explicitly, but im not sure of the difference between exiting and destroying the discord client and resources
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
in discord i see the bot go offline, but im not sure how else i would test what youre asking
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
yes, after completing the posting task, i use client.destroy()
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
and the js script calls the bot too
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
but a js script in github updates that the announcement has been made to avoid duplicate announcements
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
its static
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
it posts a random announcement based on the contents of a postgres db
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
ill look into coding this properly based on the advice given previously, thanks for your time
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
ok, can you tldr why that is please?
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
it just seemed that i wanted to trigger the bot to run as i would manually at specific times through the day
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
im not a dev so probably through ignorance
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
is that really bad
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
yeah i am :catPeek:
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
found it
44 replies
RRailway
Created by buddyswift on 4/9/2024 in #✋|help
cron not running as scheduled
44 replies