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

273
Vistas
Discord.js not registering new slash commands because application names must be unique

Discord.js won't register my commands again, despite the fact they don't exist. I've verified that the commands don't exist by running:

rest.get(Routes.applicationCommands(clientId))
    .then(data => console.log(data));

with the only response being []

The error I get is this:

DiscordAPIError[50035]: Invalid Form Body
  method: 'PUT',
  url: 'https://discord.com/api/v9/applications/985234455717363762/commands',
  requestBody: {
    files: undefined,
    json: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object]
    ]
  }
}

The code (deploy-commands.js) looks like this:

const fs = require('node:fs');
const path = require('node:path');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { clientId, token } = require('./config.json');

const commands = [];
const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
    const filePath = path.join(commandsPath, file);
    const command = require(filePath);
    commands.push(command.data.toJSON());
}

const rest = new REST({ version: '9' }).setToken(token);

rest.put(Routes.applicationCommands(clientId), { body: commands })
    .then(() => console.log('Successfully registered application commands.'))
    .catch(console.error);

With this filetree:

discord-bot/
|-- Commands/
    |-- avatar.js
    |-- beep.js
    |-- kick.js
    |-- options-info.js
    |-- ping.js
    |-- prune.js
    |-- server.js
    |-- user-info.js
|-- node_modules
|-- config.json
|-- deploy-commands.js
|-- index.js
|-- package-lock.json
|-- package.json

HELP!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This error comes if you have 2 application commands with the same name, double check your command names and make sure every command has a unique name.

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