TravBot-v3/src/events/guildCreate.ts

33 lines
1.1 KiB
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<"guildCreate">({
2021-04-01 13:41:49 +00:00
on(guild) {
$.log(
`[GUILD JOIN] ${guild.name} (${guild.id}) added the bot. Owner: ${guild.owner!.user.tag} (${
guild.owner!.user.id
}). Updated emote registry.`
);
if (Config.systemLogsChannel) {
const channel = client.channels.cache.get(Config.systemLogsChannel);
if (channel && channel.type === "text") {
(channel as TextChannel).send(
`TravBot joined: \`${guild.name}\`. The owner of this guild is: \`${guild.owner!.user.tag}\` (\`${
guild.owner!.user.id
}\`)`
);
} else {
console.warn(`${Config.systemLogsChannel} is not a valid text channel for system logs!`);
}
}
2020-12-31 16:10:56 +00:00
updateGlobalEmoteRegistry();
}
});