Home > Enterprise >  TypeError: Cannot read properties of undefined (reading 'send')
TypeError: Cannot read properties of undefined (reading 'send')

Time:01-25

I am writing a discord bot with node.js. I want the bot to send a message automatically when a member joins or leaves the channel. But I keep getting an error about the send function. Can you help me? [1]: https://i.stack.imgur.com/4URud.png

module.exports = (client) => {
    client.on('guildMemberRemove', (member) => {
        console.log(member);
        
    member.guild.channels.cache.get("1234567890912345678").send("byeee");
  });
}

CodePudding user response:

member.guild.channels.cache.get("1234567890912345678") is undefined, so there is no send() function. You need to identify why that channel is undefined or doesn't exist or find that channel using another method.

  •  Tags:  
  • Related