From e3cddf506dfa6f8787077293fc07ae082cc3bc21 Mon Sep 17 00:00:00 2001 From: TurboRx Date: Sat, 8 Aug 2026 15:08:15 +0000 Subject: [PATCH] fix(parser): preserve argument state when dynamic command lookups fall back --- src/command-parser.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/command-parser.js b/src/command-parser.js index 3ae6bb0..2d9459e 100644 --- a/src/command-parser.js +++ b/src/command-parser.js @@ -769,18 +769,21 @@ class DynamicCommand { case "string": this.sendReply(conf || "", context); break; - case "object": + case "object": { + let originalArg = context.arg; let spaceIndex = context.arg.indexOf(" "); let arg; if (spaceIndex === -1) { arg = Text.toCmdid(context.arg); } else { arg = Text.toCmdid(context.arg.substr(0, spaceIndex)); - context.arg = context.arg.substr(spaceIndex + 1); } let cmd = context.cmd; context.cmd += " " + arg; - if (conf[arg]) { + if (Object.prototype.hasOwnProperty.call(conf, arg)) { + if (spaceIndex !== -1) { + context.arg = context.arg.substr(spaceIndex + 1); + } this.execNext(conf[arg], context); } else if (Object.keys(conf).length > 1) { let spl = new LineSplitter(context.parser.app.config.bot.maxMessageLength); @@ -793,9 +796,11 @@ class DynamicCommand { context.errorReply(spl.getLines()); } else if (Object.keys(conf).length === 1) { arg = Object.keys(conf)[0]; + context.arg = originalArg; this.execNext(conf[arg], context); } break; + } } } }