-
Notifications
You must be signed in to change notification settings - Fork 34
/
main.js
84 lines (71 loc) · 2.11 KB
/
main.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
process.on("unhandledRejection", (error) => console.log(error));
process.on("uncaughtException", (error) => console.log(error));
const fs = require("fs-extra");
const path = require("path");
const express = require("express");
const figlet = require("figlet");
const chalk = require("chalk");
const login = require("./includes/login");
const log = require("./includes/log");
const configPath = path.join(__dirname, "json", "config.json");
const configData = fs.readFileSync(configPath);
const config = JSON.parse(configData);
const app = new express();
const port = process.env.PORT || 3000;
global.client = new Object({
startTime: new Date(),
config: config,
botPrefix: config.botPrefix,
botAdmins: config.botAdmins,
commands: new Map(),
events: new Map(),
replies: new Map(),
cooldowns: new Map(),
reactions: {},
});
global.data = new Object({
allUsers: null,
allThreads: null,
});
async function start() {
app.use(express.static("./includes/web"));
app.listen(port);
const appState = fs.readJSONSync(
path.join(__dirname, "json", "cookies.json"),
);
const utils = require("./utils");
global.utils = utils;
figlet.text("KurtV2", (err, data) => {
if (err) return log.error(err);
utils.loadAll();
console.log(chalk.cyan(data));
console.log(chalk.blue(`› Bot Name: ${config.botName}`));
console.log(chalk.blue(`› Bot Owner: ${config.botOwner}`));
console.log(chalk.blue(`› Time: ${new Date().toLocaleString()}`));
console.log(chalk.blue(`› KurtV2 is running on port: ${port}`));
console.log();
app.get("/", (req, res) => {
res.send("Online!");
});
app.listen(port);
login(
{
appState,
},
(err, api) => {
if (err) return log.error(err);
fs.writeFileSync(
"./json/cookies.json",
JSON.stringify(api.getAppState()),
);
api.setOptions(config.fcaOptions);
api.listen(async (err, event) => {
if (err) return log.error(err);
const listen = require("./includes/listen");
listen({ api, event });
});
},
);
});
}
start();