-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (33 loc) · 1.36 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
//TODO: Implement a Scoreboard System on the Bot
//TODO: Implement people adding their own Roles???? Still iffy about people abusing it buttt
if (process.version.slice(1).split(".")[0] < 8) throw new Error("Node 8.0.0 or higher is required. Update Node on your system.");
//-----------Initialization---------------
const Discord = require("discord.js");
const { promisify } = require("util");
const readdir = promisify(require("fs").readdir);
const client = new Discord.Client();
require("./modules/functions.js")(client, Discord);
client.config = require("./config.json");
client.commands = new Discord.Collection();
//-------------Function----------------------
global.wait = promisify(setTimeout);
async function start() {
const fcommand = await readdir("./commands/");
fcommand.forEach(file => {
try {
let command = require(`./commands/${file}`);
client.commands.set(command.help.name, command);
} catch (e) {
console.log(`Error: ${e} \n ${e.stack}`);
}
});
const files = await readdir("./events/");
files.forEach(file => {
const eventName = file.split(".")[0];
const event = require(`./events/${file}`);
client.on(eventName, event.bind(null, client));
delete require.cache[require.resolve(`./events/${file}`)];
});
client.login(client.config.token);
};
start();