I try to create a discord bot in Python and want to add a feature when the bot sends a message every interval of time (like every week or every month), any ideas?
You can do something like this using thediscord.ext.tasks :
import discord
from discord.ext import tasks
@tasks.loop(hours=1)
async def myFunction():
#Insert the code you want to be repeated here
myFunction.start()
An advantage is that you can set before and after triggers with @myFunction.before_loop
and @myFunction.after_loop
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.