Python discord.py如何使bot在特定日期自动发送消息?

Python discord.py如何使bot在特定日期自动发送消息?,python,discord,discord.py,Python,Discord,Discord.py,我在我的机器人上工作,它与日期有关。我想让我的discord机器人自动发送一些消息,无需命令。例如,如何使用命令在日期作出反应: bot = commands.Bot(command_prefix='!') @bot.command() async def badd(ctx): today = date.today() d1 = today.strftime("%d/%m") if d1 == '10/03': await ctx.send('Its

我在我的机器人上工作,它与日期有关。我想让我的discord机器人自动发送一些消息,无需命令。例如,如何使用命令在日期作出反应:

bot = commands.Bot(command_prefix='!')

 @bot.command()
 async def badd(ctx): 
  today = date.today()
  d1 = today.strftime("%d/%m")
  if d1 == '10/03':
   await ctx.send('Its working')
  else:
   await ctx.send('False')

所以当用户输入“!badd”-bot发送消息时。有没有不向bot发送命令的方法呢?

现在,您可以使用
任务
扩展为每个时间段创建一个循环,但您必须计算它:

from discord.ext import commands, tasks

bot = commands.Bot("!")

channelId = #put the id of the channel in here

@tasks.loop(hours=168) #in this example for every week  
async def day_schedule():
    message_channel = bot.get_channel(channelId)
    await message_channel.send("Your message")