TypeError: Cannot read property 'guild' of undefined I'm writing a welcome code but I keep getting that error

const db = require('quick.db')
const Discord = require('discord.js')

module.exports = (client) => {
  
  
    client.on('guildMemberAdd', (member, message) => {
     
        let welcomechannel = db.get(`welcome_${message.guild.id}`)
        let welcomemsg = db.get(`Welcomemsg_${message.guild.id}`)
  
       if(welcomechannel = null || undefined) return
   
        if(welcomemsg = null || undefined) welcomemsg = `Hey <@${member.id}>! Make sure to read the rules and have a great time!`

        let embed = new Discord.MessageEmbed()
        .setColor('GOLD')
        .setDescription(welcomemsg)


        welcomechannel.send(embed)
 

    })
  }

10 thoughts on “TypeError: Cannot read property 'guild' of undefined I'm writing a welcome code but I keep getting that error”

  1. The guildMemberAdd event is emitted only with a member parameter.
    You have to access the guild property from the member object.

    let welcomechannel = db.get(`welcome_${member.guild.id}`)
    let welcomemsg = db.get(`Welcomemsg_${member.guild.id}`)
    
    Reply

Leave a Comment