2022-07-20 23:01:47 +02:00
|
|
|
import loadClient from './utils/client';
|
|
|
|
import loadEvents from './events/loader';
|
|
|
|
import loadCommands from './commands/loader';
|
|
|
|
|
2022-07-20 23:47:41 +02:00
|
|
|
import { logStart } from './utils/misc';
|
|
|
|
|
2022-07-22 11:46:47 +02:00
|
|
|
/** Run the bot. */
|
2022-07-20 23:01:47 +02:00
|
|
|
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
|
2022-07-20 23:47:41 +02:00
|
|
|
const client_name = 'Client';
|
2022-07-20 23:01:47 +02:00
|
|
|
await loadClient()
|
|
|
|
.then(async client => {
|
2022-07-20 23:47:41 +02:00
|
|
|
console.log(logStart(client_name, true));
|
|
|
|
|
|
|
|
// Events Discord.JS
|
|
|
|
const events_name = 'Events';
|
2022-07-20 23:01:47 +02:00
|
|
|
await loadEvents(client)
|
2022-07-20 23:47:41 +02:00
|
|
|
.then(() => console.log(logStart(events_name, true)))
|
2022-07-20 23:01:47 +02:00
|
|
|
.catch(() => {
|
2022-07-20 23:47:41 +02:00
|
|
|
throw logStart(events_name, false);
|
2022-07-20 23:01:47 +02:00
|
|
|
});
|
|
|
|
|
2022-07-20 23:47:41 +02:00
|
|
|
// Connect the bot to Discord.com
|
2022-07-20 23:01:47 +02:00
|
|
|
await client.login(client.config.token_discord);
|
|
|
|
|
2022-07-20 23:47:41 +02:00
|
|
|
// Commands Slash Discord.JS
|
|
|
|
const commands_name = 'Commands';
|
2022-07-20 23:01:47 +02:00
|
|
|
await loadCommands(client)
|
2022-07-20 23:47:41 +02:00
|
|
|
.then(() => console.log(logStart(commands_name, true)))
|
2022-07-20 23:01:47 +02:00
|
|
|
.catch(() => {
|
2022-07-20 23:47:41 +02:00
|
|
|
throw logStart(commands_name, false);
|
2022-07-20 23:01:47 +02:00
|
|
|
});
|
|
|
|
|
2022-07-20 23:47:41 +02:00
|
|
|
console.log(`Botanique "${client.user?.username}" v${client.config.version} started!`);
|
2022-07-20 23:01:47 +02:00
|
|
|
})
|
|
|
|
.catch(() => {
|
2022-07-20 23:47:41 +02:00
|
|
|
throw logStart(client_name, false);
|
2022-07-20 23:01:47 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
run().catch(error => console.error(error));
|