Вы можете проверить разрешения для целей так же, как вы проверяете права авторов в своем текущем коде, используя атрибут sevrer_permissions
:
from discord import Member
from discord.ext.commands import Bot, has_permissions, CheckFailure, BadArgument
bot = Bot("!")
@bot.command(pass_context=True, name="kick")
@has_permissions(kick_members=True)
async def kick_command(ctx, *, target: Member):
if target.server_permissions.administrator:
await bot.say("Target is an admin")
else:
try:
await bot.kick(target)
await bot.say("Kicked")
except Exception:
await bot.say("Something went wrong")
@kick_command.error
async def kick_error(error, ctx):
if isinstance(error, CheckFailure):
await bot.send_message(ctx.message.channel, "You do not have permissions")
elif isinstance(error, BadArgument):
await bot.send_message(ctx.message.channel, "Could not identify target")
else:
raise error