This repository has been archived by the owner on Jan 27, 2021. It is now read-only.
/
index.js
53 lines (45 loc) · 1.43 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
45
46
47
48
49
50
51
52
53
const Db = require("./database"),
Discord = require("./discord"),
Log = require("./log"),
Tmi = require("./tmi");
// # #
// # #
// ### ### ### ### ### # # ###
// ## # # # # # # # # # #
// ## # # ## # # # # # #
// ### ## # # # ## ### ###
// #
/**
* Starts up the application.
*/
(async function startup() {
Log.log("Starting up...");
// Set the window title.
if (process.platform === "win32") {
process.title = "SixBotGG";
} else {
process.stdout.write("\x1b]2;SixBotGG\x1b\x5c");
}
// Get streamers and hosted channels.
let data;
try {
data = await Db.getStreamersAndHosts();
} catch (err) {
setTimeout(startup, 60000);
Log.exception("There was a database error getting streamers and hosted channels. Retrying in 60 seconds...", err);
return;
}
Log.log("Got streamer data.");
// Startup tmi
Tmi.startup();
await Tmi.connect();
// Startup Discord
Discord.startup();
await Discord.connect();
// Add streamers and hosts.
data.streamers.forEach((streamer) => Discord.addStreamer(streamer));
data.hosts.forEach((host) => Discord.addHost(host));
}());
process.on("unhandledRejection", (err) => {
Log.exception("Unhandled promise rejection caught.", err);
});