This repository has been archived by the owner on Aug 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
75 lines (68 loc) · 2.06 KB
/
index.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const Eris = require("eris")
require("dotenv").config()
const bot = new Eris(process.env.TOKEN)
bot.commands = new Map()
try {
let commands = require("fs").readdirSync("./commands").filter(f => f.split(".").pop() === "js")
if(commands.length === 0) {
console.log("No commands to load!\n")
} else {
let c = 0;
for(let i = 0; i < commands.length; i++) {
const cmd = commands[i].slice(0, -3)
try {
const props = require(`./commands/${commands[i]}`)
bot.commands.set(props.info.name, props)
console.log(`Successfully loaded command ${cmd}`)
c++
} catch(err) {
const trace = err.stack.toString().split("\n").slice(0, 3).join("\n")
console.log(`An error occurred while trying to load ${cmd}\n${trace}`)
console.log(`Could not load the command ${cmd}`)
}
}
console.log(`Loaded ${c} commands.\n`)
}
} catch(err) {
console.error(err)
}
try {
let files = require("fs").readdirSync("./events").filter(f => f.split(".").pop() === "js")
if(files.length === 0) {
console.log("No events to load!")
} else {
let e = 0;
for(let i = 0; i < files.length; i++) {
const _event = files[i].slice(0, -3)
try {
const event = require(`./events/${files[i]}`)
bot.on(_event, event.bind(null, bot))
console.log(`Successfully loaded event ${_event}.`)
e++
} catch(err) {
const trace = err.stack.toString().split("\n").slice(0, 3).join("\n")
console.log(`An error occurred while trying to load ${_event}\n${trace}`)
console.log(`Could not load the event ${_event}.`)
}
}
console.log(`Loaded ${e} events.`)
}
} catch(err) {
console.error(err)
}
bot.connect()
Map.prototype.filter = function(fn, thisArg) {
if (thisArg) fn = fn.bind(thisArg);
const results = new Map();
for (const [key, val] of this) {
if (fn(val, key, this)) results.set(key, val);
}
return results;
}
Map.prototype.map = function(fn, thisArg) {
if (thisArg) fn = fn.bind(thisArg);
const arr = new Array(this.size);
let i = 0;
for (const [key, val] of this) arr[i++] = fn(val, key, this);
return arr;
}