• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

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

i was coding my welcome message on my discord bot, but when someone enters in the server, console give me this error:

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

here is my guildMemberAdd.js code:

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

module.exports = {
name: "guildMemberAdd",
execute(member) {
    const MemberRole = member.guild.roles.cache.get('891716789879316540');
    member.roles.add(MemberRole);
    
    const WelcomeEmbed = new MessageEmbed()
    .setColor('RANDOM')
    .setAuthor('WELCOME', member.user.displayAvatarURL({dynamic: true}))
    .setDescription(`Welcome ${member} in our server!\n you are the number ${member.guild.memberCount}`)
    .setFooter(`${member.user.tag}`, member.user.displayAvatarURL({dynamic: true}))
    .setTimestamp();
    member.guild.channel.cache.get('768526997882142743').send({content: `${member}`, embeds: [WelcomeEmbed]});

    const LogEmbed = new MessageEmbed()
    .setColor('GREEN')
    .setDescription(`${member} came in our server`)
    .setTimestamp();

    member.guild.channel.cache.get('768526997882142743').send({embeds: [LogEmbed]});
    }
}

the strange thing is that on the 6th line it works fine, but in the 15th line and in the 22th doesn't works

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

0

Simple typo in channel:

member.guild.channel.cache.get('768526997882142743')

Should be:

member.guild.channels.cache.get('768526997882142743')
about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error