Discord.py using multiple permission check decorators on command methods

Viewed 167

I'm making a command test. I only want the user to be able to use the command when they either;

  • Are the bot owner
  • Have the manage_channels permission

At the moment I am doing

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

But as soon as I - the bot owner - try to use it without the manage_channels permission it does not work. I assume it is blocked by @commands.has_permissions() as soon as it sees I don't have the permission?

I know I could always just check in the method itself, but I understand using the decorators is the better way?

Thanks in advance.

1 Answers

You can use the commands.check_any decorator

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

Reference:

Related