Discord.py 在命令方法上使用多个权限检查装饰器

Discord.py using multiple permission check decorators on command methods

我正在执行命令 test。 我只希望用户能够在任何时候使用该命令;

此刻我在做

@client.command()
@commands.has_permissions(manage_channels=True)
@commands.check(commands.is_owner())
async def test(ctx):
  await ctx.reply("Success!")

但是一旦我——机器人所有者——尝试在没有 manage_channels 许可的情况下使用它,它就无法工作。我假设它一看到我没有权限就被 @commands.has_permissions() 阻止了?

我知道我总是可以检查方法本身,但我知道使用装饰器是更好的方法?

提前致谢。

您可以使用 commands.check_any 装饰器

@client.command()
@commands.check_any(commands.is_owner(), commands.has_permissions(manage_channels=True))
async def ...

参考: