【发布时间】:2020-10-28 22:15:24
【问题描述】:
所以我完成了我的静音命令,然后我在一个人身上进行了测试,它成功了。但是当涉及到对不同的人静音时,它不会。我将一个人静音 1 分钟,将另一个人静音 10 秒。因为我先做了 1m 静音,所以它先静音,然后我对另一个人做了 10 秒静音。它等到一分钟静音完成后才进行 10 秒静音。如何阻止这种情况发生? 这是我的代码:
@client.command()
@commands.has_role("Mod")
async def mute(ctx, user : discord.Member, duration = 0,*, unit = None):
roleobject = discord.utils.get(ctx.message.guild.roles, id=730016083871793163)
await ctx.send(f":white_check_mark: Muted {user} for {duration}{unit}")
await user.add_roles(roleobject)
if unit == "s":
wait = 1 * duration
time.sleep(wait)
elif unit == "m":
wait = 60 * duration
time.sleep(wait)
await user.remove_roles(roleobject)
await ctx.send(f":white_check_mark: {user} was unmuted")
没有错误。
【问题讨论】: