我正在制造一个不和谐的机器人,该机器人为用户提供命令角色,然后删除该角色。我想要它,这样我就可以一次运行多个计时器。现在,我正在使用pythons线程模块的Timer函数。我正在等待使用计时器函数调用的函数时出现错误。我该怎么做,还是有更好的方法?
//the actual command
@bot.command(name='ban', help = "bans the specified account for 10 minutes")
async def ban(ctx, user:discord.Member):
role = get(user.guild.roles, name = ban_role)
await user.add_roles(role)
last = ctx.channel.last_message_id
message = await ctx.channel.fetch_message(int(last))
await message.add_reaction("\u2705")
timer = Timer(10, deleterole(user, role))
timer.start()
//the delete role function
async def deleterole(user, role):
await user.remove_roles(role)