Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

351
Visualizações
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 Respostas
Responde à pergunta

0

Member has guild property:

const guild = member.guild
const channel = guild.channels.cache.get(WelcomeChannel)
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda