-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.js
39 lines (36 loc) · 1.09 KB
/
main.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
//importing modules etc...
const Discord = require("discord.js");
const client = new Discord.Client();
const config = require("./config");
const fs = require("fs");
const chalk = require('chalk')
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
//Commands
fs.readdir("./commands/", (err, files) => {
if (err) console.log(err);
let jsfile = files.filter((f) => f.split(".").pop() === "js");
if (jsfile.length <= 0) {
console.log("Couldn't find any commands");
return;
}
jsfile.forEach((f) => {
let props = require(`./commands/${f}`);
console.log(`${f} Loaded`);
client.commands.set(props.help.name, props);
props.help.aliases.forEach((alias) => {
client.aliases.set(alias, props.help.name);
});
});
});
//Client Events
fs.readdir("./events/", (err, files) => {
if (err) return console.log(err);
files.forEach((f) => {
const event = require(`./events/${f}`);
let eventName = f.split(".")[0];
console.log(`Event Loaded: ${f}`);
client.on(eventName, event.bind(null, client));
});
});
client.login(config.token);