forked from ChrisChrome/weather-bot
Backend Update
- Send a message to the user who added the bot to a guild with support link
This commit is contained in:
parent
70c30420fc
commit
845fead37a
34
index.js
34
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
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue