discord.py how to use permissions

from discord import Member
from discord.ext.commands import has_permissions, MissingPermissions

@bot.command(name="kick", pass_context=True)
@has_permissions(manage_roles=True, ban_members=True)
async def _kick(ctx, member: Member):
    await bot.kick(member)

@_kick.error
async def kick_error(error, ctx):
    if isinstance(error, MissingPermissions):
        text = "Sorry {}, you do not have permissions to do that!".format(ctx.message.author)
        await bot.send_message(ctx.message.channel, text)

Here is what the above code is Doing:
1. We’re defining a command called “kick” that takes a context and a member.
2. We’re checking if the member has the required permissions to kick.
3. If they do, we kick the member.
4. If they don’t, we send a message to the channel saying they don’t have the required permissions.