diff options
author | marzavec <admin@marzavec.com> | 2018-06-03 20:08:35 +0200 |
---|---|---|
committer | marzavec <admin@marzavec.com> | 2018-06-03 20:08:35 +0200 |
commit | 62daa4893f374c1cbbecc63e4f1d4eec3fd29325 (patch) | |
tree | f5677c91c86efd60eb78d4c6b0258b17c1926074 /server/src/managers | |
parent | Merge pull request #16 from OpSimple/master (diff) | |
download | hackchat-62daa4893f374c1cbbecc63e4f1d4eec3fd29325.tar.gz hackchat-62daa4893f374c1cbbecc63e4f1d4eec3fd29325.zip |
Completed protocol decoupling
Diffstat (limited to '')
-rw-r--r-- | server/src/managers/commands.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/server/src/managers/commands.js b/server/src/managers/commands.js index c38fb4d..fd743fb 100644 --- a/server/src/managers/commands.js +++ b/server/src/managers/commands.js @@ -182,10 +182,11 @@ class CommandManager { if (maybe) { // Found a suggestion, pass it on to their dyslexic self - return server.reply({ - cmd: 'warn', + return this.handleCommand(server, socket, { + cmd: 'socketreply', + cmdKey: server._cmdKey, text: `Command not found, did you mean: \`${maybe}\`?` - }, socket); + }); } // Request so mangled that I don't even, silently fail @@ -209,12 +210,12 @@ class CommandManager { } if (missing.length > 0) { - let errText = `Failed to execute '${command.info.name}': missing required ${missing.join(', ')}\n\n`; - - server.reply({ - cmd: 'warn', - text: errText - }, socket); + console.log(`Failed to execute '${command.info.name}': missing required ${missing.join(', ')}\n\n`); + this.handleCommand(server, socket, { + cmd: 'socketreply', + cmdKey: server._cmdKey, + text: `Failed to execute '${command.info.name}': missing required ${missing.join(', ')}\n\n` + }); return null; } @@ -226,10 +227,11 @@ class CommandManager { let errText = `Failed to execute '${command.info.name}': ${err}`; console.log(errText); - server.reply({ - cmd: 'warn', + this.handleCommand(server, socket, { + cmd: 'socketreply', + cmdKey: server._cmdKey, text: errText - }, socket); + }); return null; } |