-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
114 lines (83 loc) · 3.21 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
const Eris = require("eris");
const colors = require("colors");
const fs = require("fs");
const recursive = require("recursive-readdir");
const config = require("./config.js");
const { initLiveCrypto } = require("./modules/cryptoManager.js");
const { deploySlashCommands } = require("./modules/slashManager.js");
require("./utils/awaitMessages");
const init = async () => {
const client = new Eris(config.token, {
intents: ["allPrivileged"],
allowedMentions: [],
});
console.log("\n\nLoading...\n\n".brightRed);
client.commands = new Map();
client.slashCommands = new Map();
client.aliases = new Map();
let fileNumber = 0;
// load events
fs.readdir("./events/", (err, files) => {
console.log(`\nEvents : (` + `${files.length}`.bold.yellow + ")");
if (err) return console.error(err);
files.forEach((eventFile) => {
// load only js files
if (!eventFile.endsWith(".js")) return;
// retrive path
const event = require(`./events/${eventFile}`);
// get name from path
let eventName = eventFile.split(".")[0];
// bind it
client.on(eventName, event.bind(null, client));
console.log(`Loading event : `.white + `${eventName}`.blue);
fileNumber = fileNumber + 1;
});
});
// load commands
recursive("./commands/", (err, files) => {
if (err) return console.error(err);
console.log(`\n\nCommands : (` + `${files.length}`.bold.yellow + ")");
files.forEach((file) => {
if (!file.endsWith(".js")) return;
let props = require(`./${file}`);
let filePath = file.replace(/\\/g, "/"); // weird thing to avoid path issues
let commandName = filePath.split(/\//g).reverse()[0];
commandName = commandName.split(".")[0];
// register command
client.commands.set(commandName.toLowerCase(), props);
// register alias
props.config.aliases.forEach((alias) => {
client.aliases.set(alias.toLowerCase(), props.config.name.toLowerCase());
});
// format aliases list
let aliases = props.config.aliases.map((e) => e.toString()).join(", ");
console.log(`Loaded command : ` + `${commandName}`.brightRed);
console.log(`Aliases : ` + `${aliases}`.cyan);
fileNumber = fileNumber + 1;
});
console.log(`\nLoaded ` + `${fileNumber}`.yellow + ` files.`);
});
// load slash
recursive("./slashCommands/", async (err, files) => {
if (err) return console.error(err);
console.log(`\n\nSlashCommands : (` + `${files.length}`.bold.yellow + ")");
files.forEach((file) => {
if (!file.endsWith(".js")) return;
let props = require(`./${file}`);
let filePath = file.replace(/\\/g, "/"); // weird thing to avoid path issues
let commandName = filePath.split(/\//g).reverse()[0];
commandName = commandName.split(".")[0];
// register command
client.slashCommands.set(props.data.name.toLowerCase(), props);
console.log(`Loaded slash command : ` + `${props.data.name}`.brightRed);
fileNumber = fileNumber + 1;
});
console.log(`\nLoaded ` + `${fileNumber}`.yellow + ` files.`);
});
client.once("ready", () => {
initLiveCrypto(client);
deploySlashCommands(client);
});
client.connect();
};
init();