From 81deb86730a53b1be43600a46e92a0f0385d96f5 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Fri, 6 Sep 2019 12:00:12 -0700 Subject: [PATCH] automatically reform schemas to have options with trailing args --- bundles/chatbot/daemons/chatbot.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bundles/chatbot/daemons/chatbot.js b/bundles/chatbot/daemons/chatbot.js index 944a0ba..8b4859f 100644 --- a/bundles/chatbot/daemons/chatbot.js +++ b/bundles/chatbot/daemons/chatbot.js @@ -605,7 +605,13 @@ class ChatBot extends Daemon { // Skip if not a real command if (registeredCommand.fn === null) continue; - for (const schema of registeredCommand.schemas) { + // Add auto-generated schemas with trailing args + const schemas = registeredCommand.schemas; + schemas.forEach((schema) => { + schemas.push([...schema.filter(commandArg => commandArg.name !== undefined), ...schema.filter(commandArg => commandArg.name === undefined)]); + }); + + for (const schema of schemas) { // List of match args for command (remove input args/nulls) const commandMatchArgs = schema .map(commandArg => this._commandMatchArgToGeneric(commandArg));