'How do you make a bot that sends embed welcome messages?

I currently am having trouble running this code it used to stop the bot/replit when a person joins the bot/replit now it declares it as an empty message

let Discord = require("discord.js");
let client = new Discord.Client();

client.on("ready", () => {
  client.user.setPresence({ 'activity': { name: "Test}})
})

client.on('guildMemberAdd', member => {
 const embed = new Discord.MessageEmbed()
 .setTitle(`Welcome ${member.user.tag}!`)
 .setDescription(`You are member ${member.guild.memberCount}`)
  const channel = member.guild.channels.cache.find(ch => ch.name ===   'welcome-channel')
  channel.send({
    embeds: [embed]
  })
})

client.login("")


Solution 1:[1]

You can use client.on('guildMemberAdd') and this for the embed =>

client.on('guildMemberAdd', member => {
  const embed = new MessageEmbed()
    .setTitle(`Welcome ${member.user.tag}!`)
    .setDescription(`You are member ${member.guild.memberCount}!`)
  const channel = member.guild.channels.cache.find(ch => ch.name === 'welcome-channel')
  channel.send({
    embeds: [embed]
  })
})

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1