-
Notifications
You must be signed in to change notification settings - Fork 65
/
index.js
44 lines (41 loc) · 1.44 KB
/
index.js
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
40
41
42
43
44
import logger from './src/bot/Logger.js';
import config from './src/bot/Config.js';
import database from './src/bot/Database.js';
import bot from './src/bot/Bot.js';
import DiscordEventManager from './src/events/discord/DiscordEventManager.js';
import RestEventManagerEventManager from './src/events/rest/RestEventManager.js';
import commandManager from './src/commands/CommandManager.js';
import IntervalManager from './src/interval/IntervalManager.js';
/**
*
*/
async function start() {
await logger.debug('Loading settings');
await config.load();
await logger.info('Connecting to database');
await database.connect();
await logger.info('Creating database tables');
await database.createTables();
await database.runMigrations();
await logger.notice('Logging into discord');
await bot.start();
await logger.info('Online');
await logger.debug('Loading event listeners');
new DiscordEventManager().subscribe();
new RestEventManagerEventManager().subscribe();
await logger.debug('Loading intervals');
new IntervalManager().schedule();
await logger.notice('Registering slash commands');
await commandManager.register();
await logger.info('Started');
}
start().catch(async (error) => {
try {
await logger.critical('Bot crashed', error);
}
catch (e) {
console.error('Failed to send fatal error to monitoring', e);
}
console.error(error);
process.exit(1);
});