-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
97 lines (85 loc) · 3.15 KB
/
Copy pathindex.js
File metadata and controls
97 lines (85 loc) · 3.15 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const { Client } = require('discord.js');
const {readdir} = require('fs-nextra');
const Enmap = require('enmap');
if (process.version.slice(1).split('.')[0] < 8) throw new Error('Node 8.0.0 or higher is required. Update Node on your system.');
class GrandBot extends Client{
constructor(options){
super(options);
this.db = require('./functions/EnmapDB.js');
this.config = require('./config.json');
this.settings = new Enmap({name: 'settings', persistent: true});
this.blacklist = new Enmap({name: 'blacklist', persistent: true});
this.money = new Enmap({name: 'money', persistent: true});
this.commands = new Enmap();
this.aliases = new Enmap();
this.invspam = new Enmap();
}
permLvl(message){
let level = 0;
const ownerList = client.config.ownerIDs;
const authorizedList = client.config.authorizeIDs;
for(let i = 0; i < ownerList.length; i++){
if(ownerList[i].includes(message.author.id)) return level = 10;
}
for(let i = 0; i < authorizedList; i++){
if(authorizedList[i].includes(message.author.id)) return level = 9;
}
if (message.channel.type === "text" && message.guild.ownerID === message.author.id) return level = 5;
return level;
}
log(type, message, title) {
if (!title) title = 'Log';
console.log(`[${type}] [${title}]${message}`);
}
clean(client, text) {
if (text && text.constructor.name == 'Promise')
text = text;
if (typeof evaled !== 'string')
text = require('util').inspect(text, {
depth: 1
});
text = text
.replace(/`/g, '`' + String.fromCharCode(8203))
.replace(/@/g, '@' + String.fromCharCode(8203))
.replace(client.token, 'mfa.VkO_2G4Qv3T--NO--lWetW_tjND--TOKEN--QFTm6YGtzq9PH--4U--tG0');
return text;
};
}
String.prototype.toProperCase = function() {
return this.replace(/([^\W_]+[^\s-]*) */g, function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
};
const client = new GrandBot({
fetchAllMembers: true,
disabledEvents:['TYPING_START']
});
const init = async () => {
const cmdFiles = await readdir('./commands/');
client.log('log', `Loading a total of ${cmdFiles.length} commands.`);
cmdFiles.forEach(f => {
try {
const props = new (require(`./commands/${f}`))(client);
if (f.split('.').slice(-1)[0] !== 'js') return;
client.log('log', `Loading Command: ${props.help.name}. ✔`);
client.commands.set(props.help.name, props);
if (props.init) props.init(client);
props.conf.aliases.forEach(alias => {
client.aliases.set(alias, props.help.name);
});
} catch (error) {
client.log(`Unable to load command ${f}: ${error}`);
}
});
const evtFiles = await readdir('./events/');
client.log('log', `Loading a total of ${evtFiles.length} events.`);
evtFiles.forEach(file => {
const eventName = file.split('.')[0];
const event = new (require(`./events/${file}`))(client);
client.on(eventName, (...args) => event.execute(...args));
client.log('log', `Loading Event: ${eventName}. ✔`);
delete require.cache[require.resolve(`./events/${file}`)];
});
client.login(process.env.TOKEN);
};
init();