Search code examples
discord.js

How do I resolve the 50001-Error "Missing Access" when trying to register commands for my bot?


I am having some trouble with the registration of commands for my Discord bot. I am following the tutorial on discordjs.guide, but get an error, where they dont. When I try to run their code, I get an error in the console related to missing access of the bot. I am aware that "applications.commands" needs to be checked in the discord developer portal and that the bot needs to be kicked and re-added to the server, but despite doing all that, the error still remains.

The error looks like this:

DiscordAPIError[50001]: Missing Access
    at SequentialHandler.runRequest (<my-folder-path>\node_modules\@discordjs\rest\dist\index.js:753:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.queueRequest (<my-folder-path>\node_modules\@discordjs\rest\dist\index.js:565:14)
    at async REST.request (<my-folder-path>\node_modules\@discordjs\rest\dist\index.js:999:22) {
  rawError: { message: 'Missing Access', code: 50001 },
  code: 50001,
  status: 403,
  method: 'PUT',
  url: 'https://discord.com/api/v9/applications/<my-bot-id>/guilds/<my-guild-id>/commands',
  requestBody: { files: undefined, json: [ [Object], [Object], [Object] ] }
}

I have replaced a few irrelevant parts in the message like Ids and folder paths with general statements at "< >" due to privacy reasons.

On thing that differs from the error-message of some other folks with the same problem, is that there is no line in their message stating the request-body like there is in the last line of mine. The issue could be resolved by adding the "application.commands" permission in the bot settings, but as stated earlier, this didnt work for me. In terms of code, I am using the exact code as in the example, with my specific data filled into the config.json. My bot has the scopes of "bot" and "application.commands", as well as the bot permissions of "Administrator".

I am very thankful for every response!


Solution

  • Check if the applications.commands scope is checked in the developers portal OAuth2 section.