-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (52 loc) · 1.91 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
const Discord = require("discord.js"); // Discord.Js
const client = new Discord.Client({
disableMentions: 'everyone',
}); // The Client
const { MessageEmbed } = require('discord.js'); // Discord Message Embed
const prefix = require('discord-prefix'); // The Prefix Database
client.commands = new Discord.Collection(); // Client Commands
client.events = new Discord.Collection(); // Client Events
client.aliases = new Discord.Collection(); // Client Command Aliases
client.category = new Discord.Collection(); // Client Command Category
client.queue = new Map(); // Music Queue
client.vote = new Map(); // Music Vote
client.prefix = prefix; // Prefix As Global Variable
client.muted = require('./muted.json') // Muted Database
async function run() { // The Start Function
const fs = require("fs");
// Read Events Directory And Execute Events
fs.readdir("./events/", (err, files) => {
if (err) return console.error(err);
files.forEach(f => {
if (!f.endsWith(".js")) return;
const event = require(`./events/${f}`);
let eventName = f.split(".")[0];
client.on(eventName, event.bind(null, client));
});
});
// Read Commands Directory
await fs.readdir("./commands/",(err, directories) => {
console.log(`Loading a total of ${directories.length} categories.`);
// Separate Categories
directories.forEach(async (dir) => {
await fs.readdir("./commands/"+dir+"/", (err, commands) => {
if(err) {
return console.log(err)
}
commands.filter((cmd) => cmd.split(".").pop() === "js").forEach((cmd) => {
let pull = require(`./commands/${dir}/${cmd}`);
// Set Categories, Aliases And Commands
client.commands.set(pull.help.name, pull);
client.category.set(dir, true)
pull.help.aliases.forEach(alias => {
client.aliases.set(alias, pull.help.name)
});
});
});
});
});
// Login Into Client
client.login(process.env.TOKEN)
}
// Run The Start Function
run();