I have a function to send a randomly chosen welcome message on Discord when a user join and also add a role to it and it used to work, but after updating to Discord.js v12, I get the error
Welcome ${member}, that will be 6,99 $. Wanna pay cash or credit card?
^
TypeError: member is not a function*
when a user joins. Could someone help me, please? This is my code.
// When a member joins, this function executes.
bot.on('guildMemberAdd', (member) => {
console.log('User ' + member.id + ' has joined the guild.');
// Welcome messages possible options.
let welcomeMessages = [`${member}, welcome to our server :wave:!\n\nNow you're **one of us** :new_moon_with_face:! \n\n`,
`Welcome, ${member}. Hope you enjoy your stay.`, `Look who showed up... ${member}`, `Welcome ${member}, have a pleasant time.`,
`So... ${member} just arrived.`, `Great... ${member} is here!`, `Everyone stand up! ${member} is here.`, `Hello daddy ${member}...`
`Welcome ${member}, that will be 6,99 $. Wanna pay cash or credit card?`
];
let welcomeChannel = member.guild.channels.cache.get(serverData.welcomeChannelId);
let defaultRole = member.guild.roles.cache.get(serverData.defaultRoleId);
// Both the welcome message and GIFs will be chosen randomly.
let welcomeGif = welcomeGifs[Math.floor(Math.random() * welcomeGifs.length)];
let welcomeMessage = welcomeMessages[Math.floor(Math.random() * welcomeMessages.length)];
// This is the variable that stores the user profile picture for later use.
let newUserIcon = member.user.displayAvatarURL;
welcomeChannel.send(`${member}`);
// This is my embedded message, which allows loads of customization.
let welcomeMessageEmbed = new Discord.MessageEmbed()
.setColor(Math.floor(Math.random() * 16777214) + 1) // The color will be random.
.setDescription(welcomeMessage) // A message will be chosen randomly from the welcome messages tab.
.setImage(welcomeGif) // Same with the GIF.
.setThumbnail(newUserIcon) // The icon of the embedded message will be the user profile picture.
// Send in the embed.
welcomeChannel.send(welcomeMessageEmbed);
// This is the default role.
member.roles.add(defaultRole);
});