Cannot read property 'guild' of undefined

44 Views Asked by At

Hey,

I want to make a welcome system and it works in the index. But I have a folder events in which it is not working anymore... Of course, I have modified the code a bit.

I have this code:

const Discord = require("discord.js")
  
module.exports = async(client, message, member, interaction) => {

  function welcome(member) {
  const params = new URLSearchParams({
    avatar: member.displayAvatarURL({
      format: 'png'
    }),
    memcount: member.guild.memberCount,
    discrim: member.user.discriminator,
    name: member.user.username,
    bg: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRftGIBXNXQV02kJRDFaX9hZJ_JsG9iU74WfA&usqp=CAU",
header: "VÍTEJ!",
membertext: "{count}tý uživatel",
apikey: process.env.welcomeAPIKey
  });

   
  const image = 'https://api.badboy.is-a.dev/image/welcomecard?' + params
  return image;
}
//client.on("guildMemberAdd", member => {
    member.guild.channels.cache.get("969631692841185410").send({
        embeds: [new Discord.MessageEmbed().setImage("attachment://welcome.png")],
        files: [new Discord.MessageAttachment(welcome(member), "attachment://welcome.png")]
    })

}

But also this error: TypeError: Cannot read property 'guild' of undefined

Can someone please help me?

0

There are 0 best solutions below