I am making a discord bot using node.js and discord.js, and I am currently trying to make it so that when a user joins the discord server, a custom welcome message is sent. Here is my code:
bot.on("guildMemberAdd" ,(message, member) => {
message.channel.send("Welcome")
});
This is the error is get:
message.channel.send("Welcome")
^
TypeError: Cannot read property 'send' of undefined
Thanks for your help.
If you read the documentation, there's is no message
parameter, only member
. You will have to get the guild's channel ID first.
Try something like this:
bot.on('guildMemberAdd', member => {
member.guild.channels.get('channelID').send("Welcome");
});