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 -25Showing whitespace changes
public/scripts/slash-commands/SlashCommandCommonEnumsProvider.js+29 -0
@@ -153,6 +153,35 @@ export const commonEnumProviders = {
153 },153 },
154154
155 /**155 /**
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 /**
156 * All possible char entities, like characters and groups. Can be filtered down to just one type.185 * All possible char entities, like characters and groups. Can be filtered down to just one type.
157 *186 *
158 * @param {('all' | 'character' | 'group')?} [mode='all'] - Which type to return187 * @param {('all' | 'character' | 'group')?} [mode='all'] - Which type to return
public/scripts/variables.js+7 -25
@@ -1602,28 +1602,7 @@ export function registerVariableCommands() {
1602 typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],1602 typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
1603 isRequired: true,1603 isRequired: true,
1604 acceptsMultiple: true,1604 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 },
1627 forceEnum: false,1606 forceEnum: false,
1628 }),1607 }),
1629 ],1608 ],
@@ -1653,10 +1632,11 @@ export function registerVariableCommands() {
1653 typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],1632 typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
1654 isRequired: true,1633 isRequired: true,
1655 acceptsMultiple: true,1634 acceptsMultiple: true,
1656 enumProvider: commonEnumProviders.variables('all'),1635 enumProvider: commonEnumProviders.numbersAndVariables,
1657 forceEnum: false,1636 forceEnum: false,
1658 }),1637 }),
1659 ],1638 ],
1639 splitUnnamedArgument: true,
1660 helpString: `1640 helpString: `
1661 <div>1641 <div>
1662 Performs a multiplication of the set of values and passes the result down the pipe. Can use variable names.1642 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() {
1681 typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],1661 typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
1682 isRequired: true,1662 isRequired: true,
1683 acceptsMultiple: true,1663 acceptsMultiple: true,
1684 enumProvider: commonEnumProviders.variables('all'),1664 enumProvider: commonEnumProviders.numbersAndVariables,
1685 forceEnum: false,1665 forceEnum: false,
1686 }),1666 }),
1687 ],1667 ],
1668 splitUnnamedArgument: true,
1688 helpString: `1669 helpString: `
1689 <div>1670 <div>
1690 Returns the maximum value of the set of values and passes the result down the pipe. Can use variable names.1671 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() {
1709 typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],1690 typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME],
1710 isRequired: true,1691 isRequired: true,
1711 acceptsMultiple: true,1692 acceptsMultiple: true,
1712 enumProvider: commonEnumProviders.variables('all'),1693 enumProvider: commonEnumProviders.numbersAndVariables,
1713 forceEnum: false,1694 forceEnum: false,
1714 }),1695 }),
1715 ],1696 ],
1697 splitUnnamedArgument: true,
1716 helpString: `1698 helpString: `
1717 <div>1699 <div>
1718 Returns the minimum value of the set of values and passes the result down the pipe.1700 Returns the minimum value of the set of values and passes the result down the pipe.