-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
56 lines (47 loc) · 2.59 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
/*
██╗ ██╗ ██████╗ ████████╗ █████╗ ██████╗ ██████╗ ███╗ ███╗██████╗
██║ ██║██╔═══██╗╚══██╔══╝██╔══██╗██╔══██╗██╔═══██╗ ████╗ ████║██╔══██╗
███████║██║ ██║ ██║ ███████║██████╔╝██║ ██║█████╗██╔████╔██║██║ ██║
██╔══██║██║ ██║ ██║ ██╔══██║██╔══██╗██║ ██║╚════╝██║╚██╔╝██║██║ ██║
██║ ██║╚██████╔╝ ██║ ██║ ██║██║ ██║╚██████╔╝ ██║ ╚═╝ ██║██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝
By : Taira Makino
Github : https://github.com/anonphoenix007
WhatsApp : https://wa.me/2347080968564
*/
const fs = require("fs").promises;
const path = require("path");
const config = require("./config");
const connect = require("./lib/connection");
const { getandRequirePlugins } = require("./database/plugins");
global.__basedir = __dirname;
const readAndRequireFiles = async (directory) => {
try {
const files = await fs.readdir(directory);
return Promise.all(
files
.filter((file) => path.extname(file).toLowerCase() === ".js")
.map((file) => require(path.join(directory, file)))
);
} catch (error) {
console.error("Error reading and requiring files:", error);
throw error;
}
};
async function initialize() {
console.log("HOTARO-MD");
try {
await readAndRequireFiles(path.join(__dirname, "/database/"));
console.log("Syncing Database");
await config.DATABASE.sync();
console.log("📥 Installing HOTARO-MD Plugins...");
await readAndRequireFiles(path.join(__dirname, "/plugins/"));
await getandRequirePlugins();
console.log("✅ Plugins Successfully Installed!");
return await connect();
} catch (error) {
console.error("Initialization error:", error);
return process.exit(1); // Exit with error status
}
}
initialize();