#DiscordAPIError[50001] when registering application commands

1 messages · Page 1 of 1 (latest)

severe kindle
#

I seem to be unable to register commands using REST.
Code:

/**
 * Registers all commands into the REST API.
 */
export const registerCommands = async (): Promise<void> => {
    try {
        const rest = new discord.REST().setToken(token);
        const id = client.user?.id as string;
        const guild = config["mainGuild"].toString();
        await rest.put(discord.Routes.applicationGuildCommands(id, guild), {
            body: commands.map((command) => command.data.toJSON())
        });
        echoDebug("Successfully registered application commands.");
    } catch (error: any) {
        console.error(error);
    }
};

Repo: https://github.com/0tickpulse/tickmc-bot
Error:

>> registercommands
DiscordAPIError[50001]: Missing Access
    at SequentialHandler.runRequest (C:\Users\...\Stuff\Sprites\djs bot\node_modules\@discordjs\rest\dist\index.js:659:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.queueRequest (C:\Users\...\Stuff\Sprites\djs bot\node_modules\@discordjs\rest\dist\index.js:458:14)
    at async REST.request (C:\Users\...\Stuff\Sprites\djs bot\node_modules\@discordjs\rest\dist\index.js:902:22)
    at async Module.registerCommands (file:///C:/Users/.../Stuff/Sprites/djs%20bot/dist/server.js:116:9)
    at async file:///C:/Users/.../Stuff/Sprites/djs%20bot/dist/events/ready.js:25:17 {
  requestBody: { files: undefined, json: [ [Object] ] },
  rawError: { message: 'Missing Access', code: 50001 },
  code: 50001,
  status: 403,
  method: 'PUT',
  url: 'https://discord.com/api/v10/applications/1009769639791820852/guilds/967071106261459000/commands'
}
>>
GitHub

Contribute to 0tickpulse/tickmc-bot development by creating an account on GitHub.

pine flint
#

your token or client/guild id is invalid

severe kindle
#

You sure? I just ran the debugger and made sure that all three were correct

#

The token variable is the same one used for the client.login

tiny palm
#

do you have the correct permissions and scopes for your bot on your server?

pine flint
#

and bot have scope?

#

I mean application.commands scope

severe kindle
#

I'm not sure. Should I re-invite the bot with the scope?

pine flint
#

yeah, try it

severe kindle
#

And to double check, I get the link from here, right?

pine flint
#

and bot

#

if you need it of course

#

but I'm sure you are

severe kindle
#

What the hell is that deformed apple

#

Nah, that wasn't it.

#

wait a minute

#

Ah I think I got it

#

In the config i have mainGuild: 967071106261459000 instead of 967071106261458954 for some reason

#

(how did it get rounded ?!?!?!)

pine flint
#

probably because it wasn't string?

#

make sure it is, because numbers are too small to hold discords Snowflake

severe kindle
#

Yeah it seems so

#
Logged in as GigabitDC#7565 (1009769639791820852)!
>> registercommands
Successfully registered application commands.
>>
#

hey i think that was it