I am making a Discord Bot that will greet users with a warm welcome, with no setup.
What I want it to do: I want it to find a channel with the name "welcome" and send a embed to it
What is actually does: It doesnt send anything. My help command uses the same thing but it doesn't work in the GuildMemberAdd event
Here is my code:
client.on("guildMemberAdd", (member) => {
try {
let embed = new Discord.MessageEmbed;
embed.setTitle(`Welcome, ${member.username}!`)
embed.setAuthor(message.author.username, message.author.avatarURL)
embed.setDescription('We hope you enjoy your stay!')
console.log(`New User "${member.user.username}" has joined "${member.guild.name}"` );
const channel = member.guild.channels.cache.find(c => c.name === "welcome").id
channel.send(embed);
} catch(err) {
console.log(err)
}