I am trying to deploy my bot commands when I'm getting the Invalid Form Body error?
// Send the commands to the specified guild to be deployed
console.log(cmdsData);
rest.put(
Routes.applicationGuildCommands(
process.env.CLIENT_ACTIVE_ID as string,
process.env.GUILD_ACTIVE_ID as string
),
{ body: cmdsData }
).then(() => {
UtilHelpers.success("Successfully deployed commands.");
}).catch((err: any) => {
UtilHelpers.error(err);
reject(new Error("Unable to deploy commands."));
});
The cmdsData is an array of the RESTPostAPIApplicationGuildCommandsJSONBody type
This is what I push to the cmdsData array
function RollOutCommand(cmdsData: RESTPostAPIApplicationGuildCommandsJSONBody[], cmd: Command) {
try {
cmdsData.push(cmd.data.toJSON());
UtilHelpers.success(`Successfully rolled-out command with name: '${cmd.data.name}'`);
} catch (reason: any) {
UtilHelpers.error(reason);
UtilHelpers.error(`Unable to deploy command with name: '${cmd.data.name}' as the command data is invalid.`);
}
}
My example command
import { Client, SlashCommandBuilder, CommandInteraction } from "discord.js";
import { Command } from "../Interfaces/Command";
module.exports = {
data: new SlashCommandBuilder()
.setName("test")
.setDescription("This is a test command which is used for testing the first command"),
execute: async (interaction: CommandInteraction) => {
await interaction.reply("Test command recieved!");
}
};

