Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 7 additions & 29 deletions src/events/guildMemberAdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down