W
W
Wolf_Yout2021-09-23 20:44:09
Python
Wolf_Yout, 2021-09-23 20:44:09

How to check the rights of the bot?

Somewhere I saw a permission check using if, now I'm trying to find it but I can't find anything
I tried:

if commands.bot_has_guild_permissions == 'administration':
        await ctx.reply('У меня не хватает права `administrator`')

But it doesn't work, can you please tell me how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wolf_Yout, 2021-09-23
@Wolf_Yout

I found the answer to my question:

@commands.bot_has_permissions(manage_messages=True)

Also at the end you need to add error output:
@bot.event
async def on_command_error(ctx, error):
  if isinstance(error, commands.BotMissingPermissions):
    await ctx.reply(embed = discord.Embed(title=f'Ошибка',description=f'Извини, но у меня нет прав!', colour = discord.Color.red()))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question