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

188
Views
Obtención de error: "Error de tipo: no se puede leer la propiedad 'canales' de indefinido"

Aquí está mi código:

 module.exports = { name: 'suggestions', aliases: ['suggest'], execute(message, args, cmd, client, discord) { let channel = message.guild.channel.cache.find(ch=>ch.id==='890313569260937247') if(!channel) return message.channel.send({ content: 'There is no suggestion channel on this Server!' }); let messageArgs = args.join(' ') const embed = new Discord.MessageEmbed() .setColor('#008000') .setAuthor(message.author.tag) .setDescription(messageArgs) .setTitle(`${message.author.tag} has a suggestion!!`) message.channel.send({ embeds: [embed] }) } }

Básicamente, estoy creando un comando con mi controlador de comandos, haciendo un comando de sugerencia, donde los argumentos de un usuario se enviarán en un MessageEmbed.

Si ejecuto el comando real, aparece este error:

 TypeError: Cannot read property 'channel' of undefined at Object.execute (D:\Programming\Workspaces\Discord Bots\Mita Bot v1\commands\suggestions.js:5:37) at module.exports (D:\Programming\Workspaces\Discord Bots\Mita Bot v1\events\guild\message.js:11:25) at Client.emit (node:events:394:28) at MessageCreateAction.handle (D:\Programming\Workspaces\Discord Bots\Mita Bot v1\node_modules\discord.js\src\client\actions\MessageCreate.js:31:18) at Object.module.exports [as MESSAGE_CREATE] (D:\Programming\Workspaces\Discord Bots\Mita Bot v1\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (D:\Programming\Workspaces\Discord Bots\Mita Bot v1\node_modules\discord.js\src\client\websocket\WebSocketManager.js:345:31) at WebSocketShard.onPacket (D:\Programming\Workspaces\Discord Bots\Mita Bot v1\node_modules\discord.js\src\client\websocket\WebSocketShard.js:443:22) at WebSocketShard.onMessage (D:\Programming\Workspaces\Discord Bots\Mita Bot v1\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10) at WebSocket.onMessage (D:\Programming\Workspaces\Discord Bots\Mita Bot v1\node_modules\discord.js\node_modules\ws\lib\event-target.js:132:16) at WebSocket.emit (node:events:394:28)
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Como dijo t.niese en su comentario , Message#guild puede ser null . Si message.guild === null , esto significa que el mensaje se envió en un DM.

Comprueba primero si el mensaje se envió en un gremio:

 if (!message.guild) return message.channel.send('This command can only be used in a server!') const channel = message.guild.channels.get('890313569260937247') if (!channel) return message.channel.send('There is no suggestion channel on this Server!')

Algunos otros puntos:

  • No hay propiedad de channel en Guild ; use channels en su lugar.
  • Puede usar Collection#get para obtener un canal por su id (no es necesario usar .find(c => c.id === someId) .
  • Puede usar una cadena directamente en send : channel.send('the message') en lugar de channel.send({ content: 'the message' }) .
about 4 years ago · Juan Pablo Isaza Report

0

'channel' no es una propiedad de la clase Guild, probablemente quiso decir Guild#channels que devuelve el tipo necesario de GuildChannelManager.

about 4 years ago · Juan Pablo Isaza 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!