Why join and then split again, eh?
- Refactor /add actually using the array provided as the array for the internal `parseNumericSeries` inside `performOperation`
This commit is contained in:
parent
140aeb2bb7
commit
0d38e63471
|
@ -669,8 +669,8 @@ function deleteGlobalVariable(name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a series of numeric values from a string.
|
* Parses a series of numeric values from a string or a string array.
|
||||||
* @param {string} value A space-separated list of numeric values or variable names
|
* @param {string|string[]} value A space-separated list of numeric values or variable names
|
||||||
* @param {SlashCommandScope} scope Scope
|
* @param {SlashCommandScope} scope Scope
|
||||||
* @returns {number[]} An array of numeric values
|
* @returns {number[]} An array of numeric values
|
||||||
*/
|
*/
|
||||||
|
@ -679,9 +679,8 @@ function parseNumericSeries(value, scope = null) {
|
||||||
return [value];
|
return [value];
|
||||||
}
|
}
|
||||||
|
|
||||||
const array = value
|
const values = Array.isArray(value) ? value : value.split(' ');
|
||||||
.split(' ')
|
const array = values.map(i => i.trim())
|
||||||
.map(i => i.trim())
|
|
||||||
.filter(i => i !== '')
|
.filter(i => i !== '')
|
||||||
.map(i => isNaN(Number(i)) ? Number(resolveVariable(i, scope)) : Number(i))
|
.map(i => isNaN(Number(i)) ? Number(resolveVariable(i, scope)) : Number(i))
|
||||||
.filter(i => !isNaN(i));
|
.filter(i => !isNaN(i));
|
||||||
|
@ -1595,7 +1594,7 @@ export function registerVariableCommands() {
|
||||||
}));
|
}));
|
||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||||
name: 'add',
|
name: 'add',
|
||||||
callback: (args, /**@type {string[]}*/value) => addValuesCallback(args, value.join(' ')),
|
callback: (args, value) => addValuesCallback(args, value),
|
||||||
returns: 'sum of the provided values',
|
returns: 'sum of the provided values',
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
SlashCommandArgument.fromProps({
|
SlashCommandArgument.fromProps({
|
||||||
|
|
Loading…
Reference in New Issue