diff --git a/public/scripts/slash-commands/SlashCommand.js b/public/scripts/slash-commands/SlashCommand.js index 209e685fc..d83a157de 100644 --- a/public/scripts/slash-commands/SlashCommand.js +++ b/public/scripts/slash-commands/SlashCommand.js @@ -36,6 +36,7 @@ export class SlashCommand { * @param {(namedArguments:NamedArguments|NamedArgumentsCapture, unnamedArguments:string|SlashCommandClosure|(string|SlashCommandClosure)[])=>string|SlashCommandClosure|Promise} [props.callback] * @param {string} [props.helpString] * @param {boolean} [props.splitUnnamedArgument] + * @param {Number} [props.splitUnnamedArgumentCount] * @param {string[]} [props.aliases] * @param {string} [props.returns] * @param {SlashCommandNamedArgument[]} [props.namedArgumentList] @@ -53,6 +54,7 @@ export class SlashCommand { /**@type {(namedArguments:{_pipe:string|SlashCommandClosure, _scope:SlashCommandScope, _abortController:SlashCommandAbortController, [id:string]:string|SlashCommandClosure}, unnamedArguments:string|SlashCommandClosure|(string|SlashCommandClosure)[])=>string|SlashCommandClosure|Promise}*/ callback; /**@type {string}*/ helpString; /**@type {boolean}*/ splitUnnamedArgument = false; + /**@type {Number}*/ splitUnnamedArgumentCount; /**@type {string[]}*/ aliases = []; /**@type {string}*/ returns; /**@type {SlashCommandNamedArgument[]}*/ namedArgumentList = []; diff --git a/public/scripts/slash-commands/SlashCommandParser.js b/public/scripts/slash-commands/SlashCommandParser.js index 3110dc4cd..84a37b914 100644 --- a/public/scripts/slash-commands/SlashCommandParser.js +++ b/public/scripts/slash-commands/SlashCommandParser.js @@ -797,7 +797,7 @@ export class SlashCommandParser { cmd.startUnnamedArgs = this.index - /\s(\s*)$/s.exec(this.behind)?.[1]?.length ?? 0; cmd.endUnnamedArgs = this.index; if (this.testUnnamedArgument()) { - cmd.unnamedArgumentList = this.parseUnnamedArgument(cmd.command?.unnamedArgumentList?.length && cmd?.command?.splitUnnamedArgument); + cmd.unnamedArgumentList = this.parseUnnamedArgument(cmd.command?.unnamedArgumentList?.length && cmd?.command?.splitUnnamedArgument, cmd?.command?.splitUnnamedArgumentCount); cmd.endUnnamedArgs = this.index; if (cmd.name == 'let') { const keyArg = cmd.namedArgumentList.find(it=>it.name == 'key'); @@ -846,7 +846,7 @@ export class SlashCommandParser { testUnnamedArgumentEnd() { return this.testCommandEnd(); } - parseUnnamedArgument(split) { + parseUnnamedArgument(split, splitCount = null) { /**@type {SlashCommandClosure|String}*/ let value = this.jumpedEscapeSequence ? this.take() : ''; // take the first, already tested, char if it is an escaped one let isList = split; @@ -855,6 +855,7 @@ export class SlashCommandParser { let assignment = new SlashCommandUnnamedArgumentAssignment(); assignment.start = this.index; while (!this.testUnnamedArgumentEnd()) { + if (split && splitCount && listValues.length >= splitCount) split = false; if (this.testClosure()) { isList = true; if (value.length > 0) {