forked from ChrisChrome/weather-bot
Add guild joining/leaving
This commit is contained in:
parent
5fe0190d10
commit
6733eea16a
37
index.js
37
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) => {
|
process.on("unhandledRejection", (error) => {
|
||||||
console.log(`${colors.red("[ERROR]")} Unhandled Rejection: ${error.message}`);
|
console.log(`${colors.red("[ERROR]")} Unhandled Rejection: ${error.message}`);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue