Search code examples
discord.js

Missing access error when adding a role on specific guild


I have a discord bot that adds a role to a user when under certain conditions. It's been working for other discord servers but on this specific server I always get the error:

DiscordAPIError[50001]: Missing Access

I'm using discord.js and I've confirmed the following assumptions:

  • The bot role is in a higher position than the role I'm trying to assign
  • The bot has the manage permissions enabled
  • Tried on different users

I've also tried to use the Discord Rest API instead but I get the same error.

Is there anything else I could check that might not allow me to assign a role to a user?


Solution

  • Ok, found the issue. This Discord Server requires Two-Factor Authentication and so for the bot to work, the Discord account associated with the Discord App created for the bot needed also to have 2FA enabled. As soon as 2FA was enabled for the bot developer on Discord, it started working as expected.