forked from firegods/Tagsbot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
59 lines (52 loc) · 2.03 KB
/
app.js
File metadata and controls
59 lines (52 loc) · 2.03 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
// For dashboard stuff.
// npm install body-parser ejs express express-session hbs helmet marked passport passport-discord
const { Client, Collection } = require('discord.js');
const {readdir} = require('fs-nextra');
const PersistentCollection = require('djs-collection-persistent');
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 YorkDev extends Client {
constructor(options) {
super(options);
this.db = require('./functions/PersistentDB.js');
this.config = require('./config.json');
this.settings = new PersistentCollection({name: 'settings'});
this.blacklist = new PersistentCollection({name: 'blacklist'});
this.commands = new Collection();
this.aliases = new Collection();
}
}
const client = new YorkDev({
messageCacheMaxSize: 1,
fetchAllMembers: true,
disabledEvents:['TYPING_START']
});
require('./functions/utilities.js')(client);
const init = async () => {
const cmdFiles = await readdir('./commands/');
client.log('log', `Loading a total of ${cmdFiles.length} commands.`);
cmdFiles.forEach(f => {
try {
const props = require(`./commands/${f}`);
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 (e) {
client.log(`Unable to load command ${f}: ${e}`);
}
});
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 = require(`./events/${file}`);
client.on(eventName, event.bind(null, client));
client.log('log', `Loading Event: ${eventName}. ✔`);
delete require.cache[require.resolve(`./events/${file}`)];
});
client.login(client.config.token);
};
init();