-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (34 loc) · 892 Bytes
/
index.js
File metadata and controls
41 lines (34 loc) · 892 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
38
39
40
import {CronJob} from "cron";
import {readFile} from "fs/promises";
import mysql from "mysql2";
import Bot from "./bot.js";
global.config = JSON.parse(
await readFile(
new URL('./config.json', import.meta.url)
)
);
const pools = mysql.createPool({
host: config.mysql.host,
user: config.mysql.user,
port: config.mysql.port,
password: config.mysql.password,
database: config.mysql.database,
connectionLimit: 10,
queueLimit: 0,
waitForConnections: true,
charset: 'utf8mb4',
multipleStatements: true
});
const bot = new Bot(pools);
bot.login(config.discord.key);
if ("owner" in config.discord)
bot.setOwner(config.discord.owner);
if ("jail" in config.discord)
bot.setJail(config.discord.jail);
if ("logs" in config.discord)
bot.setLog(config.discord.logs);
const job = new CronJob("0 0 * * * *", () => {
console.log("cron trigger");
bot.updateNitros();
});
job.start();