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

662
Vistas
How to fix error 50035 number type coerce when registering commands

I am trying to make a discord bot and I haven't used slash commands before as I haven't made a bot in a while, and I am getting this error when trying to register my commands:

DiscordAPIError[50035]: Invalid Form Body
application_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake.
guild_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake.
    at SequentialHandler.runRequest (/home/runner/blkt/node_modules/@discordjs/rest/dist/index.js:708:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.queueRequest (/home/runner/blkt/node_modules/@discordjs/rest/dist/index.js:511:14) {
  rawError: {
    code: 50035,
    errors: { application_id: [Object], guild_id: [Object] },
    message: 'Invalid Form Body'
  },
  code: 50035,
  status: 400,
  method: 'put',
  url: 'https://discord.com/api/v9/applications/undefined/guilds/undefined/commands',
  requestBody: { files: undefined, json: [ [Object] ] }
}

I am following the discordjs.guide tutorial and my deploy-commands.js code is this:

const token = process.env['token'];
const clientId = process.env['clientid'];
const guildId = process.env['testguildid']
const fs = require('node:fs');
const path = require('node:path');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');

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.applicationGuildCommands(clientId, guildId), { body: commands })
    .then(() => console.log('Successfully registered application commands.'))
    .catch(console.error);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

application_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake.
guild_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake.

Please make sure you are inputting right IDs as String

const clientId = process.env['clientid'];
const guildId = process.env['testguildid']

go to your .env file and make sure

clientid=ID
testguildid=ID

and make sure you are initializing config of the .env file with library like dotenv

url: 'https://discord.com/api/v9/applications/undefined/guilds/undefined/commands',

As you see here both have values of undefined

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