TravBot-v3/src/events/guildDelete.ts

25 lines
874 B
TypeScript
Raw Normal View History

2020-12-31 16:10:56 +00:00
import Event from "../core/event";
import $ from "../core/lib";
import {updateGlobalEmoteRegistry} from "../core/lib";
import {client} from "../index";
import {Config} from "../core/structures";
import {TextChannel} from "discord.js";
2020-12-31 16:10:56 +00:00
export default new Event<"guildDelete">({
2021-04-01 13:41:49 +00:00
on(guild) {
$.log(`[GUILD LEAVE] ${guild.name} (${guild.id}) removed the bot. Updated emote registry.`);
if (Config.systemLogsChannel) {
const channel = client.channels.cache.get(Config.systemLogsChannel);
if (channel && channel.type === "text") {
(channel as TextChannel).send(`\`${guild.name}\` (\`${guild.id}\`) removed the bot.`);
} else {
console.warn(`${Config.systemLogsChannel} is not a valid text channel for system logs!`);
}
}
2020-12-31 16:10:56 +00:00
updateGlobalEmoteRegistry();
}
});