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


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);
    }
}

Can i get some help with the error message? its when i send the request body to the REST it fails
Was this page helpful?