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

184
Vistas
Why can't my bot get channels? discord.js

I get this error in my console: TypeError: Cannot read property 'channels' of undefined.

The code that is causing the problem:

const channel = guild.channels.cache.find(c => c.type === 'text' && channel.permissionsFor(guild.me).has('SEND_MESSAGES'))

Index.js:

client.on("guildCreate", guild => {
  client.commands.get("joinserver").execute(guild)
});

joinserver.js:

const Discord = require("discord.js")

module.exports = {
  name: 'joinserver',
  description: '',
  execute(message, args, client, guild) {
    const channel = guild.channels.cache.find(c => c.type === 'text' && channel.permissionsFor(guild.me).has('SEND_MESSAGES'))
    const embeds = new Discord.MessageEmbed()
    channel.send(embeds)
  }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You passing your guild object into the execute function as first parameter (which is not guild but message parameter). So your guild is accessible inside execute function as message right now. You should pass guild into correct argument (4th argument in your example) or change the way how execute function receiving arguments.

client.on("guildCreate", guild => {
  // This should work: you need to pass null to `message`, `args` and `client`
  // because these arguments marked as required
  client.commands.get("joinserver").execute(null, null, null, guild)
});
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