Catch unknown command error
This commit is contained in:
parent
7ff8707520
commit
a4bf401f32
@ -24,4 +24,5 @@ let reply = {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
console.log(JSON.stringify(reply));
|
||||
|
@ -1,6 +1,11 @@
|
||||
const fs = require("fs");
|
||||
const Module = require("./module");
|
||||
|
||||
const UNKNOWN_MESSAGE = {
|
||||
format: "standard",
|
||||
message: "Unkown command"
|
||||
}
|
||||
|
||||
class ModuleManager {
|
||||
constructor() {
|
||||
console.log("Creating module manager");
|
||||
@ -24,7 +29,15 @@ class ModuleManager {
|
||||
}
|
||||
|
||||
execute(prefix, message) {
|
||||
let rawResult = this.moduleList[prefix].run(message);
|
||||
let module = this.moduleList[prefix];
|
||||
|
||||
if(module === undefined) {
|
||||
this.reply(message, UNKNOWN_MESSAGE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let rawResult = module.run(message);
|
||||
let result = JSON.parse(rawResult.toString());
|
||||
|
||||
if(result.status === "success") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user