-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathindex.js
77 lines (68 loc) · 1.91 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Impor modul dan dependensi yang diperlukan
require("./config.js");
const {
name: pkgName,
description,
author
} = require("./package.json");
const tools = require("./tools/exports.js");
const {
Consolefy
} = require("@mengkodingan/consolefy");
const CFonts = require("cfonts");
const fs = require("fs");
const http = require("http");
const path = require("path");
const SimplDB = require("simpl.db");
// Inisialisasi Consolefy untuk logging
const c = new Consolefy({
tag: pkgName
});
// Inisialisasi SimplDB untuk Database
const dbFile = path.join(__dirname, "database.json");
if (!fs.existsSync(dbFile)) fs.writeFileSync(dbFile, "{}", "utf8");
const db = new SimplDB();
// Hapus folder autentikasi jika kosong (untuk bot dengan adapter default)
if (config.bot.authAdapter.adapter === "default") {
const authDir = path.resolve(__dirname, config.bot.authAdapter.default.authDir);
if (fs.existsSync(authDir) && !fs.readdirSync(authDir).length) {
fs.rmSync(authDir, {
recursive: true,
force: true
});
}
}
// Tetapkan konfigurasi dan alat ke variabel global
Object.assign(global, {
config,
tools,
consolefy: c,
db
});
c.log("Memulai..."); // Logging proses awal
// Tampilkan nama proyek
CFonts.say(pkgName, {
font: "chrome",
align: "center",
gradient: ["red", "magenta"]
});
// Tampilkan deskripsi dan informasi pengembang
CFonts.say(
`'${description}'\n` +
`By ${author}`, {
font: "console",
align: "center",
gradient: ["red", "magenta"]
}
);
// Jalankan server jika diaktifkan dalam konfigurasi
if (config.system.useServer) {
const {
port
} = config.system;
http.createServer((_, res) => res.end(`${pkgName} berjalan di port ${port}`))
.listen(port, () => {
c.success(`Server aktif di http://localhost:${port}`);
});
}
require("./main.js"); // Jalankan modul utama