I\'m writing a discord bot using discord.py rewrite, and I want to run a function every day at a certain time. I\'m not experienced with async functions at all and I can\'t
Another option is to use apscheduler's AsyncIOScheduler, which works more naturally with async functions (such as send_channel
). In your case, you can simply write something of the form:
scheduler = AsyncIOScheduler()
scheduler.add_job(send_channel, trigger=tr)
scheduler.start()
Where tr
is a trigger object. You can use either IntervalTrigger
with a 1-day interval and a start date at 21:57, or a CronTrigger
.
Note that at the end of your program it is recommended to call shutdown()
on the scheduler object.