I am building a discord bot with discordpy and I want a function to be executed every ten minutes (for a mini game) but if I use time.sleep
the entire program will freeze and wait for that time, rendering my bot completely useless because of the fact that time.sleep
stops the program from executing. Also discordpy works with async functions and events so trying to find a place to put a while loop is very difficult. Is there a module that I can use to execute a function every ten minutes without stopping the flow of my bot?
edit: with discordpy, you define all of your async functions so:
@client.event
async def on_message(message):
# Code
And than at the end of the file you write:
client.run()
What I am saying is, I cant use an infinite while loop because of the fact that I need to reach that line, without that line the bot will be useless, So what my question is, can I "attach" a timer to my script so that every ten minutes I can execute a function?