2021-04-08 21:43:58 +00:00
|
|
|
import {client} from "../index";
|
2021-05-08 13:32:45 +00:00
|
|
|
import {TextChannel} from "discord.js";
|
2021-04-08 21:43:58 +00:00
|
|
|
import {Config} from "../structures";
|
|
|
|
|
2021-05-08 13:32:45 +00:00
|
|
|
// Logging which guilds the bot is added to and removed from makes sense.
|
|
|
|
// However, logging the specific channels that are added/removed is a tad bit privacy-invading.
|
2021-04-08 21:43:58 +00:00
|
|
|
|
2021-05-17 22:12:14 +00:00
|
|
|
client.on("guildCreate", async (guild) => {
|
|
|
|
const owner = await guild.fetchOwner();
|
|
|
|
|
|
|
|
console.log(`[GUILD JOIN] ${guild.name} (${guild.id}) added the bot. Owner: ${owner.user.tag} (${owner.user.id}).`);
|
2021-04-08 21:43:58 +00:00
|
|
|
|
|
|
|
if (Config.systemLogsChannel) {
|
|
|
|
const channel = client.channels.cache.get(Config.systemLogsChannel);
|
|
|
|
|
2021-10-29 12:52:46 +00:00
|
|
|
if (channel instanceof TextChannel) {
|
|
|
|
channel.send(
|
2021-05-17 22:12:14 +00:00
|
|
|
`TravBot joined: \`${guild.name}\`. The owner of this guild is: \`${owner.user.tag}\` (\`${owner.user.id}\`)`
|
2021-04-08 21:43:58 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
console.warn(`${Config.systemLogsChannel} is not a valid text channel for system logs!`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
client.on("guildDelete", (guild) => {
|
|
|
|
console.log(`[GUILD LEAVE] ${guild.name} (${guild.id}) removed the bot.`);
|
|
|
|
|
|
|
|
if (Config.systemLogsChannel) {
|
|
|
|
const channel = client.channels.cache.get(Config.systemLogsChannel);
|
|
|
|
|
2021-10-29 12:52:46 +00:00
|
|
|
if (channel instanceof TextChannel) {
|
|
|
|
channel.send(`\`${guild.name}\` (\`${guild.id}\`) removed the bot.`);
|
2021-04-08 21:43:58 +00:00
|
|
|
} else {
|
2021-05-08 13:32:45 +00:00
|
|
|
console.warn(
|
|
|
|
`${Config.systemLogsChannel} is not a valid text channel for system logs! Removing it from storage.`
|
|
|
|
);
|
|
|
|
Config.systemLogsChannel = null;
|
|
|
|
Config.save();
|
2021-04-08 21:43:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|