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

348
Views
Cannot t read properties of unknown reading ('cache')

I've been trying to make a welcome embed for a Discord.js bot. My problem is, that I keep getting the error:

TypeError: Cannot read properties of undefined (reading 'cache')

If I modify guild to guilds then I get this error:

TypeError: Cannot read properties of undefined (reading 'get')

I'm trying to display the amount of members in the guild (server). However, this error is preventing me. I've tried googling but I am unable to find any solutions, so I came here. I am using Discord.js v13.6 (the latest version).

The code is supposed to show an embed, when a member joins the guild. Here, of course, is my code:

const { MessageEmbed } = require('discord.js');

module.exports = {
   name: 'guildMemberAdd',
   once: false,
   execute(member) {
       console.log('New member joined')
       const WelcomeChannel = '941373101277589564'
       const guild =  member.guilds.cache.get('940180806696058910')
       const channel = member.guilds.channels.cache.get(WelcomeChannel)
       let welcomeEmbed = new MessageEmbed()
            .setDescription(`Welcome <@${member.user.id}> to the **Monocle Games** Discord server.\n Member Count: ${guild.memberCount} `)
            .setTimestamp()

        welcomeEmbed.setAuthor({
            name: '**WELCOME**',
            iconURL: member.user.avatarURL()
        })
        channel.send({embeds: [welcomeEmbed]})
   }
}

It is part of an event handler, however that is not related to the problem. My first thought was that the way I was getting the guild was outdated, however, I do believe this is the latest version, so what am I doing wrong?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Member has guild property:

const guild = member.guild
const channel = guild.channels.cache.get(WelcomeChannel)
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!