Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

649
Views
Se esperaba que recibiera un constructor SlashCommandChannelOption, pero en su lugar quedó indefinido

Mientras creaba un comando usando Discord.js v13, encontré un error interesante que parece que no puedo resolver.

Si utilizo un sistema de gestión de comandos y creo un comando con un campo de entrada de canal a través de la función Comandos de aplicación que Discord creó no hace mucho para las aplicaciones de desarrollador, me encuentro con el siguiente error cuando ejecuto la aplicación Node.js:

 F:\Development\eco-bot\node_modules\@discordjs\builders\dist\interactions\slashCommands\Assertions.js:44 throw new TypeError(`Expected to receive a ${instanceName} builder, got ${input === null ? 'null' : 'undefined'} instead.`); ^ TypeError: Expected to receive a SlashCommandChannelOption builder, got undefined instead. at Object.assertReturnOfBuilder (F:\Development\eco-bot\node_modules\@discordjs\builders\dist\interactions\slashCommands\Assertions.js:44:15) at MixedClass._sharedAddOptionMethod (F:\Development\eco-bot\node_modules\@discordjs\builders\dist\interactions\slashCommands\mixins\CommandOptions.js:76:22) at MixedClass.addChannelOption (F:\Development\eco-bot\node_modules\@discordjs\builders\dist\interactions\slashCommands\mixins\CommandOptions.js:40:21) at Object.<anonymous> (F:\Development\eco-bot\commands\faq.js:7:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:94:18)

Antes de que surjan preguntas al respecto, sí, todos los demás comandos se cargan correctamente y se envían a la API de comandos de aplicaciones de Discord y Discord los registra sin errores.

Aquí está el código que produce el problema:

 const { SlashCommandBuilder } = require('@discordjs/builders') module.exports = { data: new SlashCommandBuilder() .setName("faq") .setDescription("Send a FAQ question and answer in selected channel") .addChannelOption(channel => { channel .setName("channel") .setDescription("Channel you want to send the FAQ embed in") .setRequired(true) }), async execute (interaction) { await interaction.reply("Pong! :ping_pong:") } }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Se espera que la función que pasa como argumento al método .addChannelOption() devuelva una instancia de SlashCommandChannelOption , que en su caso es channel . Así que asegúrese de devolver el channel .

ingrese la descripción de la imagen aquí

 const { SlashCommandBuilder } = require('@discordjs/builders') module.exports = { data: new SlashCommandBuilder() .setName("faq") .setDescription("Send a FAQ question and answer in selected channel") .addChannelOption(channel => { return channel // Add return here .setName("channel") .setDescription("Channel you want to send the FAQ embed in") .setRequired(true) }), async execute (interaction) { await interaction.reply("Pong! :ping_pong:") } }
over 4 years ago · Santiago Trujillo Report

0

Yo cometí el mismo error. En la documentación, omiten las llaves {} para que puedan return implícitamente el cuerpo de la devolución de llamada. Si usa llaves, debe usar return

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!