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'
}
>>