-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdnd.js
More file actions
52 lines (43 loc) · 1.47 KB
/
dnd.js
File metadata and controls
52 lines (43 loc) · 1.47 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
51
52
const Discord = require("discord.js");
const { promisify } = require("util");
const readdir = promisify(require("fs").readdir);
const client = new Discord.Client({
disableEveryone: true,
shardCount: 1,
disabledEvents: ["TYPING_START", "CHANNEL_PINS_UPDATE"]
});
client.config = require("./config.json");
require("./modules/functions.js")(client);
const init = async () => {
const cmdFiles = await readdir("./commands/");
client.log(`Loading a total of ${cmdFiles.length} commands.`, "Commands");
cmdFiles.forEach(f => {
try {
if(!f.endsWith(".js")) return;
const command = require(`./commands/${f}`);
client.log(`Loaded Command File: ${command.help.name}.js`, "Log");
client.commands.set(command.help.name, command);
command.conf.aliases.forEach(alias => {
client.aliases.set(alias, command.help.name);
});
} catch (e){
client.log(`Unable to load command ${f}: ${e}`, "Warn");
}
});
const evtFiles = await readdir("./events/");
client.log(`Loading a total of ${evtFiles.length} events.`, "Events");
evtFiles.forEach(f => {
try {
if(f.split(".").slice(-1)[0] !== "js") return;
const event = require(`./events/${f}`);
const eventName = f.split(".")[0];
client.on(eventName, event.bind(null, client));
client.events.set(event.help.name, event);
delete require.cache[require.resolve(`./events/${f}`)];
} catch (e){
client.log(`Unable to load event ${f}: ${e}`, "Error");
}
});
client.login(client.config.clientToken);
};
init();