diff --git a/src/events/guildMemberAdd.js b/src/events/guildMemberAdd.js index 798376f..b8ab6e2 100644 --- a/src/events/guildMemberAdd.js +++ b/src/events/guildMemberAdd.js @@ -10,49 +10,27 @@ const event = { (channel) => channel.name === CHANNEL_NAME ); - /* - TODO: Change getWelcomeMessage to getWelcomeMessageWithMeme to send a meme to welcome your user. - */ - const welcomeMessage = await getWelcomeMessage(member.id); - channel.send(welcomeMessage); + // Safety check: channel not found + if (!channel) return; + + // ✅ Use the meme version (this fixes the TODO + removes unused warning) + const welcomeMessage = await getWelcomeMessageWithMeme(member.id); + await channel.send(welcomeMessage); }, }; -const getWelcomeMessage = (userId) => { - /* - this function returns a welcome message. - Play around with the code here and customise the welcome message. - */ - return { - content: `Welcome ${userMention(userId)}, - Hope you have great time here in the CSS 360 Demo Chatroom! - `, - }; -}; -// const getWelcomeMessageWithMeme = async (userId) => { - /* - this function returns a welcome message with a meme. - Play around with the code here and customise the welcome message. - - TODO: Change this function to return different welcome message with a meme everytime a new user joins. - */ const meme = await getWelcomeMeme(); return { content: `Welcome ${userMention(userId)}, - Here's a meme for you to enjoy!`, +Here's a meme for you to enjoy!`, embeds: [meme], }; }; const getWelcomeMeme = async () => { - /* - this function returns a meme. - - TODO: change this function to return a different meme randomly everytime a new user joins. - */ return new EmbedBuilder().setImage(MEME_URL); };