-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (36 loc) · 1.14 KB
/
app.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
// Load dependencies
const fs = require('fs');
const Discord = require('discord.js');
const config = require('./config.json');
const client = new Discord.Client();
fs.readdir('./events/', (err, files) => {
if (err) return console.error(err);
const jsfile = files.filter((f) => f.split('.').pop() === 'js');
if (jsfile.length <= 0) {
return console.log('No errors have been loaded!');
}
jsfile.forEach((file) => {
const event = require(`./events/${file}`);
const eventName = file.split('.')[0];
client.on(eventName, event.bind(null, client));
});
});
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
fs.readdir('./commands/', (err, files) => {
if (err) console.error(err);
const jsfile = files
.filter((t) => !t.includes('.test.'))
.filter((f) => f.split('.').pop() === 'js');
if (jsfile.length <= 0) {
return console.log('No commands have been loaded!');
}
jsfile.forEach((f) => {
const pull = require(`./commands/${f}`);
client.commands.set(pull.config.name, pull);
pull.config.aliases.forEach((alias) => {
client.aliases.set(alias, pull.config.name);
});
});
});
client.login(config.token);