check if user is owner discord.py code example

Example 1: discord py check if user is administrator

from discord.ext.commands import Bot, has_permissions, CheckFailure

client = Bot()

@client.command(pass_context=True)
@has_permissions(administrator=True)
async def whoami(ctx):
    msg = "You're an admin {}".format(ctx.message.author.mention)  
    await client.send_message(ctx.message.channel, msg)

@whoami.error
async def whoami_error(error, ctx):
    if isinstance(error, CheckFailure):
        msg = "You're an average joe {}".format(ctx.message.author.mention)  
        await client.send_message(ctx.message.channel, msg)

Example 2: discord.py check if user is bot

@bot.command()
async def kick(ctx, user: discord.Member, *, reason="No reason provided"):
    if not user.bot:
        await user.kick(reason=reason)
        await ctx.send(f"Successfully kicked {user}!")
    else:
        await ctx.send("You can't kick a bot!")