all repos — stealth-developers @ 6ec0bb9f6aa7c031bd18ccafc763e523b20320ac

apps/bot/src/index.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
import { logger } from "$/logger";
import config from "@stealth-developers/config";
import { commands, components } from "f/index";

import { client, kitten } from "@/client";

import "./events";

const main = async () => {
	try {
		await client.login(config.discord.token);
	} catch (error) {
		await client.destroy();
		logger.error(error);
		process.exit(1);
	}
};

client.once("clientReady", async (client) => {
	kitten.register({
		commands: commands,
		components: components,
	});

	await kitten.sync();
	logger.info(`logged in as ${client.user.tag}!`);

	const guilds = await client.guilds.fetch();
	logger.info(`serving ${guilds.size} guilds!`);
});

process.on("unhandledRejection", (error) => {
	logger.error(error);
});
process.on("uncaughtException", (error) => {
	logger.error(error);
});

void main();