Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

208
Vistas
I'm trying to make a slash command handler in discord.js v13

I'm trying to change my command handler to work with slash commands, but I get Invalid Form Body error when try to turn on the bot. I didn't want to have to switch handlers as that's what I use on all my bots, but I can't fix bugs either. I'm using discord js v13

This is my current command handler (index.js):

const pComandos = fs.readdirSync('Comandos');

client.commands = new Discord.Collection();
client.description = new Discord.Collection();

for (const folder of pComandos) {
    const file = fs.readdirSync('Comandos/' + folder);

    for (const comando of file) {

        let cmd = require(`./Comandos/${folder}/${comando}`);
        commandsArray = [];

        console.log(chalk.green(`[ C ] O comando ` + chalk.bold(comando) + ` foi carregado!`))

        client.commands.set(cmd.help.name, cmd)
        if (cmd.help.description) {
            cmd.desc = true
            cmd.help.description.forEach(desc => client.commands.set(desc, cmd))
        }
        client.commands.set(cmd)
        commandsArray.push(cmd.help.name);

        if (cmd.init) cmd.init(client)

        client.on("ready", async() => {
            const server = await client.guilds.cache.get("892210305558532116")
            server.commands.set(commandsArray)
        })
    }
}

Comandos/uteis/ping.js

const discord = require("discord.js");

exports.run = async (client, message, args) => {
  
  var latency = Date.now() - message.createdTimestamp

  message.reply(`<:emoji_3:892431734203891722> | My ping is: ${client.ws.ping}.\n🗺 | Timezone: ${process.env.TZ}`);

};
exports.help = {
  name: "ping",
  description: ["p"]
};

And the error:

DiscordAPIError: Invalid Form Body
0.name: This field is required
    at RequestHandler.execute (C:\Users\whash\OneDrive\Documentos\optiPC-BOT2\node_modules\discord.js\src\rest\RequestHandler.js:349:13)     
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\whash\OneDrive\Documentos\optiPC-BOT2\node_modules\discord.js\src\rest\RequestHandler.js:50:14)   
    at async GuildApplicationCommandManager.set (C:\Users\whash\OneDrive\Documentos\optiPC-BOT2\node_modules\discord.js\src\managers\ApplicationCommandManager.js:146:18) {
  method: 'put',
  path: '/applications/909489088904712223/guilds/892210305558532116/commands',
  code: 50035,
  httpStatus: 400,
  requestData: {
    json: [
      {
        name: undefined,
        description: undefined,
        type: undefined,
        options: undefined,
        default_permission: undefined
      }
    ],
    files: []
  }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to use an ApplicationCommandData object.

Instead of this:

commandsArray.push(cmd.help.name)

Do this:

commandsArray.push({
  name: cmd.help.name,
  description: cmd.help.description.join("") // or whatever description you want
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda