From 6733eea16a98d544bc3ebc40d01edb7e45aef8af Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Thu, 9 May 2024 22:32:05 -0600 Subject: [PATCH] Add guild joining/leaving --- index.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/index.js b/index.js index 934a1b9..ccff659 100644 --- a/index.js +++ b/index.js @@ -1067,6 +1067,43 @@ discord.on("interactionCreate", async (interaction) => { }); +discord.on("guildMemberAdd", (member) => { + // If it wasnt the bot, ignore + if (member.user.id !== discord.user.id) return; + // Get the main guild + const guild = discord.guilds.cache.get(config.discord.mainGuild); + // Get the log channel + const channel = guild.channels.cache.get(config.discord.logChannel); + // Send a message to the log channel + channel.send({ + embeds: [ + { + description: `I joined \`${member.guild.name}\``, + color: 0x00ff00 + } + ] + }) + +}) + +discord.on("guildMemberRemove", (member) => { + // If it wasnt the bot, ignore + if (member.user.id !== discord.user.id) return; + // Get the main guild + const guild = discord.guilds.cache.get(config.discord.mainGuild); + // Get the log channel + const channel = guild.channels.cache.get(config.discord.logChannel); + // Send a message to the log channel + channel.send({ + embeds: [ + { + description: `I left \`${member.guild.name}\``, + color: 0xff0000 + } + ] + }) +}) + process.on("unhandledRejection", (error) => { console.log(`${colors.red("[ERROR]")} Unhandled Rejection: ${error.message}`); });