🐛 Issue: Permission Error (50013) When Deleting a Role with Discord Bot
Description:
I am encountering a 50013 Permission error when my Discord bot tries to delete a role from a server. The role is confirmed to be below the bot's role in the hierarchy. The bot does have Admin permissions in the server.
Expected Behavior:
The role should be deleted without any permission errors.
Actual Behavior:
The bot throws a 50013 Permission error.
Code Snippets:
Role Removal Function:
Bot Initialization (Index File):
Any insights or solutions to this issue would be greatly appreciated.
8 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPcan you log role.managed and role.comparePositionTo(guild.members.me.roles.highest)
can you please log exactly what I asked
When I run the role.delete in my interaction command it will remove without any problems but if I run it in my guildDelete Event handler it has permission issues.
Are you deleting the role from the guild that fired the guildDelete event?
well, how do you expect the bot to remove a role on a guild the bot is not on?
No need for the condescending tone. I apologize if I misunderstood something. Thank you for helping me understand the situation. I'm uncertain about the best event to use for the 'Clean up'. I had assumed I could proceed with this particular event before the bot was removed.