Botanique/src/index.ts

51 lines
1.3 KiB
TypeScript
Raw Normal View History

import loadClient from './utils/client';
import loadEvents from './events/loader';
import loadCommands from './commands/loader';
import { logStart } from './utils/misc';
/** Run the bot */
const run = async () => {
console.log('Starting Botanique...');
// Load .env if not in prod
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
(await import('dotenv')).config({ path: './config/.env' });
}
// Client Discord.JS
const client_name = 'Client';
await loadClient()
.then(async client => {
console.log(logStart(client_name, true));
// Events Discord.JS
const events_name = 'Events';
await loadEvents(client)
.then(() => console.log(logStart(events_name, true)))
.catch(() => {
throw logStart(events_name, false);
});
// Connect the bot to Discord.com
await client.login(client.config.token_discord);
// Commands Slash Discord.JS
const commands_name = 'Commands';
await loadCommands(client)
.then(() => console.log(logStart(commands_name, true)))
.catch(() => {
throw logStart(commands_name, false);
});
console.log(`Botanique "${client.user?.username}" v${client.config.version} started!`);
})
.catch(() => {
throw logStart(client_name, false);
});
};
run().catch(error => console.error(error));