From d6d51c706c97316351b0a5322b2164722d8f2baa Mon Sep 17 00:00:00 2001 From: Tyler Potts Date: Mon, 8 Nov 2021 14:52:59 +0000 Subject: [PATCH] Welcome Members! --- bot.js | 3 ++- events/guildMemberAdd.js | 20 ++++++++++++++++++++ events/guildMemberRemove.js | 6 ++++++ events/interactionCreate.js | 1 - 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 events/guildMemberAdd.js create mode 100644 events/guildMemberRemove.js diff --git a/bot.js b/bot.js index e3b5160..b204817 100644 --- a/bot.js +++ b/bot.js @@ -5,7 +5,8 @@ const { Client, Intents, Collection } = require("discord.js"); const client = new Client({ intents: [ Intents.FLAGS.GUILDS, - Intents.FLAGS.GUILD_MESSAGES + Intents.FLAGS.GUILD_MESSAGES, + Intents.FLAGS.GUILD_MEMBERS ] }); diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js new file mode 100644 index 0000000..06570ff --- /dev/null +++ b/events/guildMemberAdd.js @@ -0,0 +1,20 @@ +const Discord = require('discord.js'); + +module.exports = { + name: "guildMemberAdd", + async execute(member) { + // member.guild.channels.cache.get("849283385808912384").send(`${member.user} has joined the server!`); + console.log(member.user); + + const newMemberEmbed = new Discord.MessageEmbed() + .setColor("#d81e5b") + .setTitle("New Member!") + .setDescription(`${member.user} has joined the server! We hope you enjoy your stay!`) + .setThumbnail(member.user.displayAvatarURL()) + .setTimestamp(); + + member.guild.channels.cache.get("849283385808912384").send({ + embeds: [newMemberEmbed] + }) + } +} \ No newline at end of file diff --git a/events/guildMemberRemove.js b/events/guildMemberRemove.js new file mode 100644 index 0000000..1150d96 --- /dev/null +++ b/events/guildMemberRemove.js @@ -0,0 +1,6 @@ +module.exports = { + name: "guildMemberRemove", + async execute(member) { + member.guild.channels.cache.get("849283385808912384").send(`${member.user} has left the server!`); + } +} \ No newline at end of file diff --git a/events/interactionCreate.js b/events/interactionCreate.js index 37965b6..f17950c 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -1,6 +1,5 @@ module.exports = { name: "interactionCreate", - once: true, // REMOVE IN NEXT TUTORIAL async execute(interaction) { if (!interaction.isCommand()) return;