I want my python discord bot to use a command every minute.
Currently I have set it up like this:
@tasks.loop(seconds=10)
async def mytask():
channel = bot.get_channel(305347032569348107)
await channel.send('Example message')
and mytask.start()
in async def on_ready()
function
It works fine and sends example message but I want it to actually execute a command, for example, I may have another bot which has a.coin command for the coin toss and I want my bot to use this command every minute.
If you look at the documentation it allows for seconds, minutes, or hours:
discord.ext.tasks.loop(*, seconds=0, minutes=0, hours=0, count=None, reconnect=True, loop=None)
So your decorator now becomes:
@tasks.loop(minutes=10)
@tasks.loop(minutes=1)
async def mytask():
channel = bot.get_channel(305347032569348107)
await channel.send(!coin)
:s
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.