aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/managers
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2018-09-30 08:44:36 +0200
committermarzavec <admin@marzavec.com>2018-09-30 08:44:36 +0200
commitc719020e17cb1c98da55be6cc7efe0e50ab51ffa (patch)
tree4c1e7f05aec2b6a995e21d2bbecbb45c2ae14bd6 /server/src/managers
parentMerge pull request #28 from henrywright/27 (diff)
downloadhackchat-c719020e17cb1c98da55be6cc7efe0e50ab51ffa.tar.gz
hackchat-c719020e17cb1c98da55be6cc7efe0e50ab51ffa.zip
Added hooks, modules and cleaned up code
Diffstat (limited to '')
-rw-r--r--server/src/managers/commands.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/server/src/managers/commands.js b/server/src/managers/commands.js
index fd743fb..a5ef464 100644
--- a/server/src/managers/commands.js
+++ b/server/src/managers/commands.js
@@ -71,8 +71,9 @@ class CommandManager {
command.info.category = category;
- if (this._categories.indexOf(category) === -1)
+ if (this._categories.indexOf(category) === -1) {
this._categories.push(category);
+ }
}
if (typeof command.init === 'function') {
@@ -114,7 +115,7 @@ class CommandManager {
/**
* Pulls all command names from a passed `category`
*
- * @param {String} category reference to the newly loaded object
+ * @param {String} category [Optional] filter return results by this category
*/
all (category) {
return !category ? this._commands : this._commands.filter(c => c.info.category.toLowerCase() === category.toLowerCase());
@@ -149,6 +150,15 @@ class CommandManager {
}
/**
+ * Runs `initHooks` function on any modules that utilize the event
+ *
+ * @param {Object} server main server object
+ */
+ initCommandHooks (server) {
+ this._commands.filter(c => typeof c.initHooks !== 'undefined').forEach(c => c.initHooks(server));
+ }
+
+ /**
* Finds and executes the requested command, or fails with semi-intelligent error
*
* @param {Object} server main server reference