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

391
Vistas
Cannot read properties of undefined (reading 'channels')

I'm trying to make an event that when someone added my bot it will send a message embed on a channel that my bot can send the message embed.

discord.js: v13.6.0

Node: v17.7.2

events/guildCreate.js

const client = require("../index");
const discord = require("discord.js")

client.on("guildCreate", async (client, guild) => {
  let channel = guild.channels.cache.find(
    channel =>
      channel.type === "text" &&
      channel.permissionsFor(guild.me).has("SEND_MESSAGES")
  );
  channel.send( new discord.MessageEmbed()
               .setDescription("**Thank you for adding me!**")
               .setColor("#fcba03"))
})

edit: I kinda of fix my problem with the reading channels:

const client = require("../index");
const { MessageEmbed } = require("discord.js")

client.on("guildCreate", async (guild, message) => {
  let channel = guild.channels.cache.find(
    channel =>
      channel.type === "text" &&
      channel.permissionsFor(guild.me).has("SEND_MESSAGES")
  );
  const embed = new MessageEmbed()
  embed.setDescription("Thank you for adding me!")
  embed.setColor("#2f3136")
  message.guild.channels.cache.get(channel).send(embed)
})

but then again got new error: TypeError: Cannot read properties of undefined (reading 'guild')

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think your “channel” is an array instead of a channel object, because you're filtering all text channels. Make sure to select the first channel of the array/collection.

Try to show what shows up when you log the “channel”

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