Help registering Slash commands

I need some help with Slash commands
DiscordAPIError[0]: 405: Method Not Allowed
at handleErrors (C:\Users\4339u\Desktop\UNORP2.2\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\4339u\Desktop\UNORP2.2\node_modules\@discordjs\rest\dist\index.js:1120:23)
at async SequentialHandler.queueRequest (C:\Users\4339u\Desktop\UNORP2.2\node_modules\@discordjs\rest\dist\index.js:953:14)
at async _REST.request (C:\Users\4339u\Desktop\UNORP2.2\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async RCMH (C:\Users\4339u\Desktop\UNORP2.2\Commands\CommandHandler.cjs:41:22)
at async C:\Users\4339u\Desktop\UNORP2.2\Commands\CommandHandler.cjs:23:13 {
requestBody: { files: undefined, json: [ [Object] ] },
rawError: { message: '405: Method Not Allowed', code: 0 },
code: 0,
status: 405,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/983360693963218945/commands/undefined'
}
DiscordAPIError[0]: 405: Method Not Allowed
at handleErrors (C:\Users\4339u\Desktop\UNORP2.2\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\4339u\Desktop\UNORP2.2\node_modules\@discordjs\rest\dist\index.js:1120:23)
at async SequentialHandler.queueRequest (C:\Users\4339u\Desktop\UNORP2.2\node_modules\@discordjs\rest\dist\index.js:953:14)
at async _REST.request (C:\Users\4339u\Desktop\UNORP2.2\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async RCMH (C:\Users\4339u\Desktop\UNORP2.2\Commands\CommandHandler.cjs:41:22)
at async C:\Users\4339u\Desktop\UNORP2.2\Commands\CommandHandler.cjs:23:13 {
requestBody: { files: undefined, json: [ [Object] ] },
rawError: { message: '405: Method Not Allowed', code: 0 },
code: 0,
status: 405,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/983360693963218945/commands/undefined'
}
Code:
async function RCMH(RCMH_Commands, token) {
try {
const rest = new D.REST().setToken(token);
console.log(`Started refreshing ${RCMH_Commands.length} application (/) commands.`);

// The put method is used to fully refresh all commands in the guild with the current set
console.log(`Commands: ${RCMH_Commands.name} \n\n`)
// process.exit(0)
const data = await rest.put(
D.Routes.applicationCommand("983360693963218945"),
{ body: RCMH_Commands },
);
console.log(`Registering Commands ${RCMH_Commands}`)

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
}
async function RCMH(RCMH_Commands, token) {
try {
const rest = new D.REST().setToken(token);
console.log(`Started refreshing ${RCMH_Commands.length} application (/) commands.`);

// The put method is used to fully refresh all commands in the guild with the current set
console.log(`Commands: ${RCMH_Commands.name} \n\n`)
// process.exit(0)
const data = await rest.put(
D.Routes.applicationCommand("983360693963218945"),
{ body: RCMH_Commands },
);
console.log(`Registering Commands ${RCMH_Commands}`)

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
}
Can i get some help with the error message? its when i send the request body to the REST it fails
3 Replies
d.js toolkit
d.js toolkit5mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
treble/luna
treble/luna5mo ago
applicationCommands
U
U5mo ago
Huh, 40 mins and i did not see that... Thanks alot!