Estoy tratando de crear un bot de discordia y no he usado comandos de barra diagonal antes, ya que no he creado un bot en mucho tiempo, y recibo este error cuando intento registrar mis comandos:
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] ] } } Estoy siguiendo el tutorialdiscordjs.guide y mi código deployment deploy-commands.js es este:
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);application_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake. guild_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake. Asegúrese de ingresar los ID correctos como String
const clientId = process.env['clientid']; const guildId = process.env['testguildid'] vaya a su archivo .env y asegúrese
clientid=ID testguildid=ID y asegúrese de que está inicializando la configuración del archivo .env con una biblioteca como dotenv
url: 'https://discord.com/api/v9/applications/undefined/guilds/undefined/commands', Como ves aquí ambos tienen valores de undefined