-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
37 lines (27 loc) · 917 Bytes
/
Copy pathapp.ts
File metadata and controls
37 lines (27 loc) · 917 Bytes
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
import { Discordbot } from "./src/Discordbot/Discordbot";
import { Logger } from "./src/Logger";
import { registerMusicPlayer } from "./src/modules/MusicPlayer/MusicPlayer";
import { getConfig } from "./src/configfile";
const log = new Logger("App");
let bot: Discordbot | undefined;
async function start() {
log.log("Starting Discobear...");
const cfg = getConfig();
bot = new Discordbot(cfg.discordToken);
await registerMusicPlayer(bot);
await bot.connect();
log.log("Discobear ready.");
}
async function stop() {
log.log("Stopping...");
if (bot) await bot.disconnect();
setTimeout(() => {
log.log("Discobear stopped.");
// Can't be bothered to look into what's keeping it alive and why.
// Bot is disconnected at this point so who cares.
process.exit();
}, 1000);
}
start();
process.on("SIGTERM", stop);
process.on("SIGINT", stop);