0

I have a timer like this:

x=datetime.datetime.today()
y = x.replace(day=x.day, hour=1, minute=0, second=0, microsecond=0) + datetime.timedelta(days=1)
delta_t=y-x
secs=delta_t.total_seconds()
Timer(secs, my_function).start()

I tried to add await like this: Timer(secs, await my_function).start() (obviously in an async funtion) But it really wants me to put only synchronous function in it. And if I don't put await before the function it gives an error the it was not awaited.

The unfortunate part is that my function that needs to be in this timer is async:

async def my_function():
    await bot.create_message("Hello World")

I tried to create a function between the two. So I am putting a synchronous function in the timer. But then I cannot run the async function in it as I cannot await it. I tried to use asyncio, which gave me the same errors. I tried to read the terminal and check for a specific word. But none of them worked. At this point I have no idea how to connect the two functions.

LGabor
  • 1
  • 1

0 Answers0