I attempted to create a basic greeter bot, but I encountered a problem where the bot would sometimes send the welcome message multiple times. I'm unsure why this is happening. Below is the code snippet causing the issue along with an image of the bug.
Here's the code:
client.on("guildMemberAdd", async (member) => {
let welcomeChannel = member.guild.channels.cache.find(channel => channel.name === "đź‘Źwelcome");
let welcomer = new Discord.MessageEmbed()
.setTitle(`${member.guild.name}`)
.setColor("#FF8A00")
.setThumbnail("https://i.redd.it/f1u2wf28nqn21.jpg")
.setDescription(`Welcome ${member.user.username}! Random number: D-${getRandomInt(0, 9)}${getRandomInt(0, 9)}${getRandomInt(0, 9)}${getRandomInt(0, 9)}`);
welcomeChannel.send(welcomer);
});