Started commandLoader.js

This commit is contained in:
ahoZiorce
2018-07-01 19:03:43 +02:00
parent 2143cb5f41
commit 1fcb230963
2 changed files with 6 additions and 2 deletions

View File

@@ -4,12 +4,12 @@ exports.endpoint = function endpoint (match, handler) {
commands[match] = handler;
};
exports.apply = function apply (command) {
exports.apply = function apply (command, context) {
let keys = Object.keys(commands);
for (let i = 0; i < keys.length; i++) {
let match = command.match(keys[i]);
if (match) {
commands[keys[i]](match);
commands[keys[i]](match, context);
return true;
}
}

4
src/commandLoader.js Normal file
View File

@@ -0,0 +1,4 @@
const fs = require('fs');
const commandH = require('./commandHandler');
fs.readdirSync();