My last post got incorrectly marked as duplicate. I am not trying to do asyncio.sleep, becuase it is too inaccurate over the space of weeks. I need the schedule library.
I found a similar thread: How can I run an async function using the schedule library? This did not help me, or the OP of the thread. I ended up with the same error as him, which he stated in a comment of the only answer.
My goal is to run a function (which must be async) every x seconds. (Set to seconds for testing purposes. The finished code will use days.)
My simplified code to try do this:
@bot.event
async def schedTest():
print("Scheduled Message Here")
@bot.command(pass_context=True)
async def announcements(ctx):
schedule.every(1).seconds.do(
bot.loop.call_soon_threadsafe, schedTest)
After executing the command announcements
,the result of this is nothing. No error or prints in the output.
This is not the same issue as the thread that this was marked as duplicate as. I am trying to get the schedule library to work, not asyncio.sleep. Sleep is not accurate over the duration of a week.
If it isn't possible, could someone advise a way to do a scheduled function accurate to a few minutes over several weeks? As this is what I'm pretty much trying to achieve.