Update /mul, /max and /min definition - Update command definition for /mul, /max and /min to fit the actual code behind, split them too - Add numbersAndVariables enum provider, to centralize

4855f254192de90d39e235c72d3e8511d5581e96

Wolfsblvt <wolfsblvt@gmail.com>

2 files changed, +36 -25Ignore whitespace
public/scripts/slash-commands/SlashCommandCommonEnumsProvider.js+29 -0
@@ -153,6 +153,35 @@ export const commonEnumProviders = {
153153 },
154154
155155 /**
156+ * Enum values for numbers and variable names
157+ *
158+ * Includes all variable names and the ability to specify any number
159+ *
160+ * @param {SlashCommandExecutor} executor - The executor of the slash command
161+ * @param {SlashCommandScope} scope - The scope of the slash command
162+ * @returns {SlashCommandEnumValue[]} The enum values
163+ */
164+ numbersAndVariables: (executor, scope) => [
165+ ...commonEnumProviders.variables('all')(executor, scope),
166+ new SlashCommandEnumValue(
167+ 'any variable name',
168+ null,
169+ enumTypes.variable,
170+ enumIcons.variable,
171+ (input) => /^\w*$/.test(input),
172+ (input) => input,
173+ ),
174+ new SlashCommandEnumValue(
175+ 'any number',
176+ null,
177+ enumTypes.number,
178+ enumIcons.number,
179+ (input) => input == '' || !Number.isNaN(Number(input)),
180+ (input) => input,
181+ ),
182+ ],
183+
184+ /**
156185 * All possible char entities, like characters and groups. Can be filtered down to just one type.
157186 *
158187 * @param {('all' | 'character' | 'group')?} [mode='all'] - Which type to return
public/scripts/variables.js+7 -25
@@ -1602,28 +1602,7 @@ export function registerVariableCommands() {
16021602 typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
16031603 isRequired: true,
16041604 acceptsMultiple: true,
1605- enumProvider: (executor, scope) => {
1605+ enumProvider: commonEnumProviders.numbersAndVariables,
1606- const vars = commonEnumProviders.variables('all')(executor, scope);
1607- vars.push(
1608- new SlashCommandEnumValue(
1609- 'any variable name',
1610- null,
1611- enumTypes.variable,
1612- enumIcons.variable,
1613- (input) => /^\w*$/.test(input),
1614- (input) => input,
1615- ),
1616- new SlashCommandEnumValue(
1617- 'any number',
1618- null,
1619- enumTypes.number,
1620- enumIcons.number,
1621- (input) => input == '' || !Number.isNaN(Number(input)),
1622- (input) => input,
1623- ),
1624- );
1625- return vars;
1626- },
16271606 forceEnum: false,
16281607 }),
16291608 ],
@@ -1653,10 +1632,11 @@ export function registerVariableCommands() {
16531632 typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
16541633 isRequired: true,
16551634 acceptsMultiple: true,
16561635 enumProvider: commonEnumProviders.variables('all')numbersAndVariables,
16571636 forceEnum: false,
16581637 }),
16591638 ],
1639+ splitUnnamedArgument: true,
16601640 helpString: `
16611641 <div>
16621642 Performs a multiplication of the set of values and passes the result down the pipe. Can use variable names.
@@ -1681,10 +1661,11 @@ export function registerVariableCommands() {
16811661 typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
16821662 isRequired: true,
16831663 acceptsMultiple: true,
16841664 enumProvider: commonEnumProviders.variables('all')numbersAndVariables,
16851665 forceEnum: false,
16861666 }),
16871667 ],
1668+ splitUnnamedArgument: true,
16881669 helpString: `
16891670 <div>
16901671 Returns the maximum value of the set of values and passes the result down the pipe. Can use variable names.
@@ -1709,10 +1690,11 @@ export function registerVariableCommands() {
17091690 typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
17101691 isRequired: true,
17111692 acceptsMultiple: true,
17121693 enumProvider: commonEnumProviders.variables('all')numbersAndVariables,
17131694 forceEnum: false,
17141695 }),
17151696 ],
1697+ splitUnnamedArgument: true,
17161698 helpString: `
17171699 <div>
17181700 Returns the minimum value of the set of values and passes the result down the pipe.