forked from AlexzanderFlores/WOKCommands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFeatureHandler.js
31 lines (31 loc) · 1.21 KB
/
FeatureHandler.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
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var fs_1 = __importDefault(require("fs"));
var get_all_files_1 = __importDefault(require("./get-all-files"));
var FeatureHandler = /** @class */ (function () {
function FeatureHandler(client, dir) {
if (dir) {
if (fs_1.default.existsSync(dir)) {
var files = get_all_files_1.default(dir);
var amount = files.length;
if (amount > 0) {
console.log("WOKCommands > Loaded " + amount + " listener" + (amount === 1 ? '' : 's') + ".");
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
var file = files_1[_i][0];
var func = require(file);
if (typeof func === 'function') {
func(client);
}
}
}
}
else {
throw new Error("Listeners directory \"" + dir + "\" doesn't exist!");
}
}
}
return FeatureHandler;
}());
module.exports = FeatureHandler;