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

387
Views
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 answers
Answer question

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 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!