python discord bot check user that sent message permissions code example
Example 1: how to limit a command to a permission in discord.py
@client.command()
@commands.has_permissions(administrator=True)
async def foo(ctx):
await ctx.send("Hello")
Example 2: discord py check if user has permission return message if not
@bot.command()
@has_permissions(kick_members=True)
async def kick(self, ctx, Member: discord.Member):
await bot.kick(Member)
@kick.error
async def kick_error(error, ctx):
if isinstance(error, MissingPermissions):
await ctx.send("You don't have permission to do that!")