This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
/
index.js
37 lines (33 loc) · 1.6 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
const Discord = require("discord.js");
const fs = require("fs");
const Settings = global.Settings = require("./Settings/Settings.json");
console.log("Launching bot...");
let _client = new Discord.Client();
if (Settings.Private_Server === true) {
_client = new Discord.Client({
fetchAllMembers: true
});
}
const client = global.client = _client;
const Commands = global.Commands = new Map();
console.log("--------------------------------");
console.log("Loading commands...");
fs.readdirSync("./Commands", { encoding: "utf-8" }).filter(file => file.endsWith(".js")).forEach(file => {
let prop = require(`./Commands/${file}`);
if (prop.conf.commands == undefined || prop.run == undefined) return console.error(`[COMMAND] ${file} is not load.`);
if (prop.conf.commands && prop.conf.commands.length > 0) {
prop.conf.commands.forEach(aliase => Commands.set(aliase, prop));
}
if (prop.onLoad != undefined && typeof (prop.onLoad) == "function") prop.onLoad(client);
console.log(`[COMMAND] A total of ${prop.conf.commands.length} supporters have been installed for ${file}.`);
});
console.log("--------------------------------");
console.log("Loading events...");
fs.readdirSync("./Events", { encoding: "utf-8" }).filter(file => file.endsWith(".js")).forEach(file => {
let prop = require(`./Events/${file}`);
client.on(prop.conf.event, prop.execute);
console.log(`[EVENT] ${file} is loaded.`);
});
console.log("--------------------------------");
console.log("| Preparation has been completed. Starting the bot now |");
require("./bot.js");