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