-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (42 loc) · 1.4 KB
/
Copy pathindex.js
File metadata and controls
50 lines (42 loc) · 1.4 KB
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
// Imports and Discord.JS
const Discord = require("discord.js");
const client = new Discord.Client();
const Enmap = require("enmap");
const { promisify } = require("util");
const readdir = promisify(require("fs").readdir);
const logger = require("./functions/Logger");
// Bot Requirements
client.commands = new Enmap();
client.aliases = new Enmap();
client.cfg = require("./config.json");
client.logger = require("./functions/Logger");
require("./functions/functions")(client);
// Logger Logic
switch (client.cfg.loglevel) {
case "debug":
logger.level = "debug";
logger.debug("Started in Debug Mode.");
break;
default:
logger.level = "info";
break;
}
const init = async () => {
const cmdFiles = await readdir("./commands/");
client.logger.debug(`Loading a total of ${cmdFiles.length} commands.`);
cmdFiles.forEach((f) => {
if (!f.endsWith(".js")) return;
const response = client.loadCommand(f);
if (response) console.log(response);
});
const evtFiles = await readdir("./events/");
client.logger.debug(`Loading a total of ${evtFiles.length} events.`);
evtFiles.forEach((file) => {
const eventName = file.split(".")[0];
client.logger.debug(`Loading Event: ${eventName}`);
const event = require(`./events/${file}`);
client.on(eventName, event.bind(null, client));
});
client.login(client.cfg.token);
};
init();