This repository was archived by the owner on Jan 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
81 lines (62 loc) · 2.16 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const { Client, Collection, MessageEmbed } = require('discord.js');
const walk = require('walk');
class Embed extends MessageEmbed {
constructor(data) {
super(data);
this.hexColor = '#7289da';
}
};
class Equalizer extends Client {
constructor(options) {
super(options);
this.config = require('./config.json');
this.Embed = Embed;
// cache
this.plugins = new Collection();
this.commands = new Collection();
}
permCheck(msg) {
let perm = 0;
if (msg.member.hasPermission('MANAGE_MESSAGE')) perm = 1;
if (msg.member.hasPermission('KICK_MEMBERS')) perm = 2;
if (msg.member.hasPermission('BAN_MEMBERS')) perm = 3;
if (msg.member.hasPermission('ADMINISTRATOR')) perm = 4;
if (msg.guild.ownerID === msg.author.id) perm = 5;
if (this.config.admins.includes(msg.author.id)) perm = 6;
if (this.config.owners.includes(msg.author.id)) perm = 7;
return perm;
}
};
const client = new Equalizer({
fetchAllMembers: true,
disableEveryone: true
});
// plugin system reee
walk.walk(`${__dirname}/src/plugins`)
.on('directories', function(root, dirs) {
for (var dir of dirs) {
let plugin = new (require(`./src/plugins/${dir.name}/plugin`))(client);
client.plugins.set(plugin.name, plugin);
// handle the commands of each plugin
walk.walk(`${__dirname}/src/plugins/${dir.name}/${plugin.CommandsFolder}`)
.on('files', function(root, files) {
for (var file of files) {
let Command = new (require(`./src/plugins/${dir.name}/${plugin.CommandsFolder}/${file.name}`))(client);
if (!Command.plugin)
Command.plugin = plugin.name;
client.commands.set(Command.name.toLowerCase(), Command);
}
});
}
});
// Handle the events
walk.walk(`${__dirname}/src/events`)
.on('files', function(root, files) {
files = files.filter(file => file.name.endsWith('.js'));
for (var file of files) {
let event = new (require(`./src/events/${file.name}`))(client);
if (event.ignored) continue;
client.on(event.name, (...args) => event.run(...args));
}
});
client.login(client.config.token);