From 845fead37ae4de39f16784cbcc8301f382cd441c Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Thu, 15 Aug 2024 22:33:18 -0600 Subject: [PATCH] Backend Update - Send a message to the user who added the bot to a guild with support link --- index.js | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 9a9bca6..707b06d 100644 --- a/index.js +++ b/index.js @@ -1442,20 +1442,48 @@ discord.on("interactionCreate", async (interaction) => { break; } - - }); -discord.on("guildCreate", (guild) => { +discord.on("guildCreate", async (guild) => { + let logs = await guild.fetchAuditLogs() + logs = logs.entries.filter(e => e.action === Discord.AuditLogEvent.BotAdd) + let user = logs.find(l => l.target?.id === discord.user.id)?.executor // Get the main guild const myGuild = discord.guilds.cache.get(config.discord.mainGuild); // Get the log channel const channel = myGuild.channels.cache.get(config.discord.logChannel); // Send a message to the log channel + let invite = await discord.guilds.cache.get(config.discord.mainGuild).channels.cache.get(config.discord.inviteChannel).createInvite(); + user.send({ + embeds: [{ + description: `Thanks for adding ${discord.user.username}!\nIf you have **ANY** questions, comments, suggestions, bug reports, etc, please feel free to throw it by us in our support server!\n\nTo get started use \`/subscribe\` to get alerts!`, + color: 0x00ff00 + }], + components: [ + { + type: Discord.ComponentType.ActionRow, + components: [ + { + type: Discord.ComponentType.Button, + url: `https://discord.gg/${invite.code}`, + style: Discord.ButtonStyle.Link, + emoji: "ℹ", + label: "IEM Alerter Support Server" + } + ] + } + ] + }) channel.send({ embeds: [ { description: `I joined \`${guild.name}\``, + fields: [ + { + "name": "User", + "value": `<@${user.id}> (@${user.username}) ${user.displayName}` + } + ], color: 0x00ff00 } ]