-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.js
More file actions
75 lines (75 loc) · 2.62 KB
/
init.js
File metadata and controls
75 lines (75 loc) · 2.62 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
module.exports = function(commands, triggers, users, history) {
loadCommands = function(bot) {
commands = [];
try {
var dir = dpath.resolve(__dirname, './commands') + '/';
fs.readdirSync(dir).forEach(function (file) {
if (file.indexOf(".js") > -1) {
var command = reload(dir + file);
commands.push(command);
}
});
reloadGlobals(bot);
console.log("[INIT] " + commands.length + " Commands loaded...");
} catch (e) {
console.error('Unable to load command: ', e.stack);
}
}
loadGames = function(bot) {
try {
var dir = dpath.resolve(__dirname, './games') + '/';
fs.readdirSync(dir).forEach(function (file) {
if (file.indexOf(".js") > -1) {
reload(dir + file)(bot);
}
});
console.log("[INIT] Games loaded...");
} catch (e) {
console.error('Unable to load games: ', e.stack);
}
}
loadEvents = function(bot) {
try {
var dir = dpath.resolve(__dirname, './events') + '/';
fs.readdirSync(dir).forEach(function (file) {
if (file.indexOf(".js") > -1) {
reload(dir + file)(bot);
}
});
console.log("[INIT] Events loaded...");
} catch (e) {
console.error('Unable to load event: ', e.stack);
}
}
loadFunctions = function(bot) {
try {
var dir = dpath.resolve(__dirname, './functions') + '/';
fs.readdirSync(dir).forEach(function (file) {
if (file.indexOf(".js") > -1) {
reload(dir + file)(bot);
}
});
console.log("[INIT] Functions loaded...");
} catch (e) {
console.error('Unable to load function: ', e.stack);
}
}
loadTriggers = function(bot) {
triggers = reload('./triggers.json');
reloadGlobals(bot);
console.log("[INIT] Triggers loaded...");
}
loadUsers = function(bot) {
users = reload('./users.json');
reloadGlobals(bot);
console.log("[INIT] Users loaded...");
}
loadHistory = function(bot) {
history = reload('./history.json');
reloadGlobals(bot);
console.log("[INIT] History loaded...");
}
reloadGlobals = function(bot) {
reload('./globals')({bot: bot, config: config, triggers: triggers, commands: commands, users: users, history: history});
}
}