Trying to register commands: DiscordAPIError[50001]: Missing Access

Viewed 24422

Following this; https://discordjs.guide/creating-your-bot/creating-commands.html#command-deployment-script

I'm trying to run node deploy-commands.js to register my commands to a single guild and I'm getting the following error.

    C:\Users\\\\hello-world-discord-bot>node deploy-commands.js
DiscordAPIError[50001]: Missing Access
    at SequentialHandler.runRequest (C:\\\\\hello-world-discord-bot\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.js:198:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.queueRequest (C:\\\\\hello-world-discord-bot\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.js:99:20)
    at async C:\\\\\hello-world-discord-bot\deploy-commands.js:17:3 {
  rawError: { message: 'Missing Access', code: 50001 },
  code: 50001,
  status: 403,
  method: 'put',
  url: 'https://discord.com/api/v9/applications/877359061669118003/guilds/447125601757691915/commands'
}

I've tried removing the bot and re-permissioning it via the developer web console before re-adding it. I've checked and re-added the token clientId and guildId and I get the same error message every time. I can see it's not getting access but I've no idea where else access would be granted from.

My deploy-commands.js looks like this:

{
    "clientId": "123456789012345678",
    "guildId": "876543210987654321",
    "token": "my-token-goes-here"
}
5 Answers

Have you made sure that the 'applications.commands' scope is checked in the scopes section of the OAuth2 settings for your bot in the discord developer portal?

jh316's answer works with the additional context, for us noobs, that checking that box also requires copying the URL, pasting it in a browser so that you can access the authentication page where you get to choose the Discord server the authorization will apply to...and then click 'Authorize' in order to complete the authorization. Then running the deploy-commands.js script will run successfully.

Although I had checked 'applications.commands' it would still not work for me.

The solution was quite simple, I had copied the id of a text channel when I should have copied the server's id.

I stumbled into this error, in my case the issue was guildId being a number and not a string.

If some one has the related problem => 1/ Check your developer Page if the Plugin 'applications.commands' at OAuth2 settings checked! 2/ If still not work, just re-invite the bot and haveit "USE SLASH COMMANDS" Permission!

Related