async def background_task(ctx):
await client.wait_until_ready()
channel = client.get_channel(id=123123123123)
role1 = discord.utils.get(ctx.guild.roles, id=321321321321)
while not client.is_closed():
t = datetime.datetime.now()
cur_time = t.strftime("%H")
if int(cur_time) == 18:
await channel.send(f"{role1.mention} daily reminder!")
await asyncio.sleep(3540)
client.loop.create_task(background_task())
该功能应该向每个角色为“ role1”的用户发送提醒消息。如果我没有提到该角色,则该函数有效,但是当我尝试运行上述代码时,控制台将返回错误TypeError:background_task()缺少1个必需的位置参数:'ctx'。