forked from arynapril/RoBot-v5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
35 lines (31 loc) · 970 Bytes
/
bot.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
const Discord = require('discord.js');
const bot = new Discord.Client(require("./config.json").opts);
require('./funcs.js')(bot);
const readdir = require("fs").readdir;
bot.commands = new Discord.Collection();
bot.aliases = new Discord.Collection();
readdir('./modules/', (err, files) => {
bot.log(`Loading ${files.length} commands!`);
files.forEach(f => {
try {
var name = require(`./modules/${f}`).name
bot.commands.set(name, require(`./modules/${f}`));
/*commandFile.aliases.forEach(alias => {
bot.aliases.set(alias, commandFile.help.name);
});*/
} catch (e) {
bot.log(`Unable to load command ${f}: ${e}`);
}
});
bot.log(`Commands loaded!`);
});
readdir('./events/', (err, files) => {
bot.log(`Loading ${files.length} events!`);
files.forEach(file => {
bot.on(file.split(".")[0], (...args) => {
require(`./events/${file}`).run(bot, ...args);
});
});
bot.log(`Events loaded!`);
});
bot.login(require("./config.json").token);