Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Discord.py missing permissions when bot role is above all and has admin privileges

raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'test' raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

Constantly getting this error, even though my bot has administrator permissions, also the role is located at the top of the tree.

Showing the bot's role is located at the top

Bot has admin permissions

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Evem with all of this, I continuously get the error of missing permissions. My role is located underneath the bot’s and also has administrative permissions, so I’m not quite sure why this problem is happening.

@tree.command(name='test', description='testing the bot', guild=guild)
async def self(interaction: discord.Interaction, user:discord.User, *, nickname:str):
    await interaction.user.edit(nick=nickname)
    await interaction.response.send_message(user.mention, ephemeral=True)

>Solution :

I think the issue is that you’re using interaction.user and not user. interaction.user is the user that invoked the command. As this is likely you, the server owner, it fails as a bot can’t edit the server owner’s nickname.

@tree.command(name='test', description='testing the bot', guild=guild)
async def test(interaction: discord.Interaction, user: discord.User, *, nickname: str):
    await user.edit(nick=nickname)
    await interaction.response.send_message(user.mention, ephemeral=True)

Additionally, it might be worth explicitly adding the "manage nicknames" permission as well.

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading