-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
66 lines (49 loc) · 2.1 KB
/
index.js
File metadata and controls
66 lines (49 loc) · 2.1 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const { Client, Store, EmbedBuilder } = require('jcord');
const Enmap = require('enmap');
let { readdirSync } = require('fs');
class Embed extends EmbedBuilder {
constructor(data) {
super(data);
this.color = 0x36393F;
this.timestamp = new Date();
}
};
class Unique extends Client {
constructor(options = {}) {
super(options);
// System
this.embed = Embed;
// Properties & options
this.commands = new Store();
this._processDir = __dirname;
this.config = require('./config');
this.db = new Enmap({ name: 'unique_db' });
this.disabledEvents = options.disabledEvents || [];
this.disabledPlugins = Array.isArray(options.disabledPlugins) ? options.disabledPlugins.map(item => item.toLowerCase()) : [];
}
permissionCheck(msg) {
let perm = 0;
if (msg.member.permissions.has('manageMessages')) perm = 1;
if (msg.member.permissions.has('kickMembers')) perm = 2;
if (msg.member.permissions.has('banMembers')) perm = 3;
if (msg.member.permissions.has('administrator')) perm = 4;
if (msg.channel.guild.owner ? msg.channel.guild.owner.id === msg.author.id : msg.channel.guild.ownerID === msg.author.id) perm = 5;
if (this.config.owners.includes(msg.author.id)) perm = 6;
return perm;
}
};
const client = new Unique({ logger: true, disabledPlugins: [], shardCount: 'auto' });
// Let us load the plugins here
let plugins = readdirSync('./plugins');
for (var i = 0; i < plugins.length; i++) {
if (!(readdirSync(`./plugins/${plugins[i]}`).includes('plugin.js')))
client.emit('error', new Error(`Invalid Plugin: ${plugins[i]} No plugin.js file`));
let plugin = new (require(`./plugins/${plugins[i]}/plugin`))(client);
if (plugin.disabled || client.disabledPlugins.includes(plugins[i].toLowerCase())) {
client.customLog(`DISABLED PLUGIN`, 'red', `Plugin: ${plugins[i]} was disabled! Will not run the plugin.`);
continue;
}
if (plugins[i].toLowerCase() !== 'commands' && plugins[i].toLowerCase() !== 'events') continue;
plugin.run();
};
client.initiate(client.config.token);