Backend Update

- Send a message to the user who added the bot to a guild with support link
This commit is contained in:
Christopher Cookman 2024-08-15 22:33:18 -06:00
parent 70c30420fc
commit 845fead37a
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -1442,20 +1442,48 @@ discord.on("interactionCreate", async (interaction) => {
break; 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 // Get the main guild
const myGuild = discord.guilds.cache.get(config.discord.mainGuild); const myGuild = discord.guilds.cache.get(config.discord.mainGuild);
// Get the log channel // Get the log channel
const channel = myGuild.channels.cache.get(config.discord.logChannel); const channel = myGuild.channels.cache.get(config.discord.logChannel);
// Send a message to the log channel // 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({ channel.send({
embeds: [ embeds: [
{ {
description: `I joined \`${guild.name}\``, description: `I joined \`${guild.name}\``,
fields: [
{
"name": "User",
"value": `<@${user.id}> (@${user.username}) ${user.displayName}`
}
],
color: 0x00ff00 color: 0x00ff00
} }
] ]