This repository has been archived by the owner on Jun 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathbot.js
56 lines (49 loc) · 1.85 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const Discord = require("discord.js");
const Enmap = require("enmap");
const fs = require("fs");
const klaw = require("klaw");
const path = require("path");
const config = require('./library/configuration');
const client = new Discord.Client();
client.config = config;
client.commands = new Enmap();
client.aliases = new Enmap();
client.snipeMap = new Map();
require("./utils.js")(client);
if (config.production != 'false') {
const DBL = require("dblapi.js");
const dbl = new DBL(config.dblToken, client);
dbl.on('posted', () => {
console.log('Server count has been posted');
});
dbl.on('error', err => {
console.log(`${err}`);
});
}
const start = async () => {
fs.readdir("./events/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, event.bind(null, client));
});
});
klaw("./commands").on("data", (item) => {
const cmdFile = path.parse(item.path);
if (!cmdFile.ext || cmdFile.ext !== ".js") return;
try {
let props = require(`${cmdFile.dir}${path.sep}${cmdFile.name}${cmdFile.ext}`)
console.log(`Loading Command: ${props.help.name}${" ".repeat(25 - props.help.name.length)}👌`);
client.commands.set(props.help.name, props);
if (props.help.aliases) props.help.aliases.forEach(alias => {
client.aliases.set(alias, props);
});
} catch (e) {
return console.log(new Error(`FAIL: ${cmdFile.name}: ${e.stack}`));
};
});
console.log('I am prepared to decimate them weebs with my otaku-desu status ÒwÓ');
client.login(config.botToken);
};
start();