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

Question:

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

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)
Asked By: doare

||

Answers:

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

Answered By: ESloman
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.