wannabemathematician
wannabemathematician

Reputation: 31

if there a way to check does the author have perms but if i am (bot owner) is the author it works regardless

I want my code to check if the the message author has perms to delete messages but at the same time if I(bot owner) am the author i want it to work regardless of perms

@client.command(aliases = ['clear'])
@commands.has_permissions(manage_messages = True)
async def purge(ctx , number : int = None):
    if number is None:
        await ctx.send("Please enter number of messages to delete with the command")
        await ctx.message.delete()
    else:
        await ctx.channel.purge(limit = number + 1)

here is my code

Upvotes: 0

Views: 36

Answers (1)

Łukasz Kwieciński
Łukasz Kwieciński

Reputation: 15689

Use the commands.check_any decorator

@client.command(aliases=["clear"])
@commands.check_any(commands.has_permissions(manage_messages=True), commands.is_owner())
async def purge ...

Reference:

Upvotes: 3

Related Questions