From a865f6252fe32775716fe7bd1f1b967ec7e51808 Mon Sep 17 00:00:00 2001 From: xeovalyte Date: Thu, 22 Dec 2022 18:29:38 +0100 Subject: [PATCH] Added guildmemberadd --- discord-bot/events/guildMemberAdd.js | 16 ++++++++++++++++ discord-bot/index.js | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 discord-bot/events/guildMemberAdd.js diff --git a/discord-bot/events/guildMemberAdd.js b/discord-bot/events/guildMemberAdd.js new file mode 100644 index 0000000..bd4e6bc --- /dev/null +++ b/discord-bot/events/guildMemberAdd.js @@ -0,0 +1,16 @@ +const { Events, EmbedBuilder } = require('discord.js'); + +module.exports = { + name: Events.GuildMemberAdd, + async execute({ client, log }, member) { + log.Info(`${member.user.username} has joined`); + + const newMemberEmbed = new EmbedBuilder() + .setTitle(`${member.user.username} has joined!`) + .setDescription(`Welcome ${member} to the **Polarcraft** Discord server!`) + .setThumbnail(member.user.avatarURL()); + + const channel = await client.channels.cache.get(process.env.LOG_CHANNEL_ID); + channel.send({ embeds: [newMemberEmbed] }); + }, +}; diff --git a/discord-bot/index.js b/discord-bot/index.js index b258853..5079a2b 100644 --- a/discord-bot/index.js +++ b/discord-bot/index.js @@ -15,7 +15,7 @@ const log = { }; // Register client and music events -const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates] }); +const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMembers] }); client.player = new Player(client); require('./functions/player.js').registerEvents({ client, createEmbed });