forked from saiteja-madha/discord-js-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
43 lines (34 loc) · 1.14 KB
/
bot.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
require("dotenv").config();
require("module-alias/register");
require("@src/helpers/extenders");
const path = require("path");
const { validateConfig, checkForUpdates } = require("@utils/botUtils");
const { initializeMongoose } = require("@src/database/mongoose");
const { BotClient } = require("@src/structures");
global.__appRoot = path.resolve(__dirname);
// initialize client
const client = new BotClient();
client.loadCommands("src/commands");
client.loadContexts("src/contexts");
client.loadEvents("src/events");
// find unhandled promise rejections
process.on("unhandledRejection", (err) => client.logger.error(`Unhandled exception`, err));
(async () => {
validateConfig();
// initialize the database
await initializeMongoose();
// check for updates
await checkForUpdates();
// start the dashboard
if (client.config.DASHBOARD.enabled) {
client.logger.log("Launching dashboard");
try {
const { launch } = require("@root/dashboard/app");
await launch(client);
} catch (ex) {
client.logger.error("Failed to launch dashboard", ex);
}
}
// start the client
await client.login(process.env.BOT_TOKEN);
})();