forked from BFBAN/kook-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
68 lines (56 loc) · 2.27 KB
/
index.ts
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import * as fs from "fs";
import upath, { parse } from "upath";
import config from "./config";
import { bot } from "./bot";
import { exampleMenu } from "./src/commands/example/example.menu";
import { checkbanMenu } from "./src/commands/checkban/checkban.menu";
import { sitestatsMenu } from "./src/commands/sitestats/sitestats.menu";
import { helpMenu } from "./src/commands/help/help.menu";
import { invitationMenu } from "./src/commands/invitation/invitation.menu";
import { widgetMenu } from "./src/commands/widget/widget.menu";
import botEvent from "./src/lib/botEvent";
import botStatus from "./src/lib/botStatus";
import botMarket from "./src/lib/botMarket";
import { SentryManagement } from "./src/lib/sentry";
try {
class Main {
protected mode: any = [SentryManagement, botStatus, botEvent, botMarket];
protected commands: any = [helpMenu, checkbanMenu, sitestatsMenu, widgetMenu, invitationMenu];
constructor() {
this.ready();
}
ready() {
if (config.__DEBUG__) {
this.commands.concat(exampleMenu);
}
const logFolderPath = upath.join(__dirname, "", "logs", new Date().toISOString());
if (!fs.existsSync(logFolderPath)) {
fs.mkdirSync(logFolderPath, { recursive: true });
}
const errorLogStream = fs.createWriteStream(upath.join(logFolderPath, `${config.name}-error.log`), { flags: "a" });
const infoLogStream = fs.createWriteStream(upath.join(logFolderPath, `${config.name}-info.log`), { flags: "a" });
this.mode.forEach((m: new () => any) => new m());
bot.logger.fields.name = config.name;
bot.logger.addStream({ level: "error", stream: errorLogStream });
bot.logger.addStream({ level: "info", stream: infoLogStream });
bot.help = "/";
// bot.processMsg=(msg)=>{
// console.log(msg);
//
// if (msg.content[0].indexOf("/") >= 0) {
// bot.commandMap.forEach(i => {
// if (i.trigger == "")
// })
// }
// }
bot.addCommands(...this.commands);
bot.connect();
bot.logger.info("Initialization: " + config.name + " initialization start");
console.log("Initialization: " + config.name + " initialization start");
}
}
new Main();
} catch (err) {
console.log(err);
bot.logger.error(err);
}