diff --git a/public/scripts/variables.js b/public/scripts/variables.js index a2aa63687..8cacad9d7 100644 --- a/public/scripts/variables.js +++ b/public/scripts/variables.js @@ -745,90 +745,947 @@ function varCallback(args, value) { } export function registerVariableCommands() { - registerSlashCommand('listvar', listVariablesCallback, [], ' – list registered chat variables', true, true); - registerSlashCommand('setvar', (args, value) => setLocalVariable(args.key || args.name, value, args), [], 'key=varname index=listIndex (value) – set a local variable value and pass it down the pipe, index is optional, e.g. /setvar key=color green', true, true); - registerSlashCommand('getvar', (args, value) => getLocalVariable(value, args), [], 'index=listIndex (key) – get a local variable value and pass it down the pipe, index is optional, e.g. /getvar height or /getvar index=3 costumes', true, true); - registerSlashCommand('addvar', (args, value) => addLocalVariable(args.key || args.name, value), [], 'key=varname (increment) – add a value to a local variable and pass the result down the pipe, e.g. /addvar score 10', true, true); - registerSlashCommand('setglobalvar', (args, value) => setGlobalVariable(args.key || args.name, value, args), [], 'key=varname index=listIndex (value) – set a global variable value and pass it down the pipe, index is optional, e.g. /setglobalvar key=color green', true, true); - registerSlashCommand('getglobalvar', (args, value) => getGlobalVariable(value, args), [], 'index=listIndex (key) – get a global variable value and pass it down the pipe, index is optional, e.g. /getglobalvar height or /getglobalvar index=3 costumes', true, true); - registerSlashCommand('addglobalvar', (args, value) => addGlobalVariable(args.key || args.name, value), [], 'key=varname (increment) – add a value to a global variable and pass the result down the pipe, e.g. /addglobalvar score 10', true, true); - registerSlashCommand('incvar', (_, value) => incrementLocalVariable(value), [], '(key) – increment a local variable by 1 and pass the result down the pipe, e.g. /incvar score', true, true); - registerSlashCommand('decvar', (_, value) => decrementLocalVariable(value), [], '(key) – decrement a local variable by 1 and pass the result down the pipe, e.g. /decvar score', true, true); - registerSlashCommand('incglobalvar', (_, value) => incrementGlobalVariable(value), [], '(key) – increment a global variable by 1 and pass the result down the pipe, e.g. /incglobalvar score', true, true); - registerSlashCommand('decglobalvar', (_, value) => decrementGlobalVariable(value), [], '(key) – decrement a global variable by 1 and pass the result down the pipe, e.g. /decglobalvar score', true, true); - // registerSlashCommand('if', ifCallback, [], 'left=varname1 right=varname2 rule=comparison else="(alt.command)" "(command)" – compare the value of the left operand "a" with the value of the right operand "b", and if the condition yields true, then execute any valid slash command enclosed in quotes and pass the result of the command execution down the pipe. Numeric values and string literals for left and right operands supported. Available rules: gt => a > b, gte => a >= b, lt => a < b, lte => a <= b, eq => a == b, neq => a != b, not => !a, in (strings) => a includes b, nin (strings) => a not includes b, e.g. /if left=score right=10 rule=gte "/speak You win" triggers a /speak command if the value of "score" is greater or equals 10.', true, true); - const ifCmd = new SlashCommand(); - ifCmd.name = 'if'; - ifCmd.callback = ifCallback; - ifCmd.namedArgumentList.push(new SlashCommandNamedArgument( - 'left', 'left operand', [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER], true, - )); - ifCmd.namedArgumentList.push(new SlashCommandNamedArgument( - 'right', 'right operand', [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER], true, - )); - ifCmd.namedArgumentList.push(new SlashCommandNamedArgument( - 'rule', 'comparison rule', [ARGUMENT_TYPE.STRING], true, false, null, ['gt', 'gte', 'lt', 'lte', 'eq', 'neq', 'not', 'in', 'nin'], - )); - ifCmd.namedArgumentList.push(new SlashCommandNamedArgument( - 'else', 'command to execute if not true', [ARGUMENT_TYPE.CLOSURE, ARGUMENT_TYPE.SUBCOMMAND], false, - )); - ifCmd.unnamedArgumentList.push(new SlashCommandArgument( - 'command to execute if true', [ARGUMENT_TYPE.CLOSURE, ARGUMENT_TYPE.SUBCOMMAND], true, - )); - ifCmd.returns = 'result of the executed command ("then" or "else")'; - ifCmd.helpString = ` -

- Compares the value of the left operand a with the value of the right operand b, - and if the condition yields true, then execute any valid slash command enclosed in quotes and pass the - result of the command execution down the pipe. -

-

- Numeric values and string literals for left and right operands supported. -

-
- Available rules: - -
-
- Examples: - -
`; - SlashCommandParser.addCommandObject(ifCmd); - registerSlashCommand('while', whileCallback, [], 'left=varname1 right=varname2 rule=comparison "(command)" – compare the value of the left operand "a" with the value of the right operand "b", and if the condition yields true, then execute any valid slash command enclosed in quotes. Numeric values and string literals for left and right operands supported. Available rules: gt => a > b, gte => a >= b, lt => a < b, lte => a <= b, eq => a == b, neq => a != b, not => !a, in (strings) => a includes b, nin (strings) => a not includes b, e.g. /setvar key=i 0 | /while left=i right=10 rule=let "/addvar key=i 1" adds 1 to the value of "i" until it reaches 10. Loops are limited to 100 iterations by default, pass guard=off to disable.', true, true); - registerSlashCommand('times', (args, value) => timesCallback(args, value), [], '(repeats) "(command)" – execute any valid slash command enclosed in quotes repeats number of times, e.g. /setvar key=i 1 | /times 5 "/addvar key=i 1" adds 1 to the value of "i" 5 times. {{timesIndex}} is replaced with the iteration number (zero-based), e.g. /times 4 "/echo {{timesIndex}}" echos the numbers 0 through 4. Loops are limited to 100 iterations by default, pass guard=off to disable.', true, true); - registerSlashCommand('flushvar', (_, value) => deleteLocalVariable(value), [], '(key) – delete a local variable, e.g. /flushvar score', true, true); - registerSlashCommand('flushglobalvar', (_, value) => deleteGlobalVariable(value), [], '(key) – delete a global variable, e.g. /flushglobalvar score', true, true); - registerSlashCommand('add', (args, value) => addValuesCallback(args, value), [], '(a b c d) – performs an addition of the set of values and passes the result down the pipe, can use variable names, e.g. /add 10 i 30 j', true, true); - registerSlashCommand('mul', (args, value) => mulValuesCallback(args, value), [], '(a b c d) – performs a multiplication of the set of values and passes the result down the pipe, can use variable names, e.g. /mul 10 i 30 j', true, true); - registerSlashCommand('max', (args, value) => maxValuesCallback(args, value), [], '(a b c d) – returns the maximum value of the set of values and passes the result down the pipe, can use variable names, e.g. /max 10 i 30 j', true, true); - registerSlashCommand('min', (args, value) => minValuesCallback(args, value), [], '(a b c d) – returns the minimum value of the set of values and passes the result down the pipe, can use variable names, e.g. /min 10 i 30 j', true, true); - registerSlashCommand('sub', (args, value) => subValuesCallback(args, value), [], '(a b) – performs a subtraction of two values and passes the result down the pipe, can use variable names, e.g. /sub i 5', true, true); - registerSlashCommand('div', (args, value) => divValuesCallback(args, value), [], '(a b) – performs a division of two values and passes the result down the pipe, can use variable names, e.g. /div 10 i', true, true); - registerSlashCommand('mod', (args, value) => modValuesCallback(args, value), [], '(a b) – performs a modulo operation of two values and passes the result down the pipe, can use variable names, e.g. /mod i 2', true, true); - registerSlashCommand('pow', (args, value) => powValuesCallback(args, value), [], '(a b) – performs a power operation of two values and passes the result down the pipe, can use variable names, e.g. /pow i 2', true, true); - registerSlashCommand('sin', (args, value) => sinValuesCallback(args, value), [], '(a) – performs a sine operation of a value and passes the result down the pipe, can use variable names, e.g. /sin i', true, true); - registerSlashCommand('cos', (args, value) => cosValuesCallback(args, value), [], '(a) – performs a cosine operation of a value and passes the result down the pipe, can use variable names, e.g. /cos i', true, true); - registerSlashCommand('log', (args, value) => logValuesCallback(args, value), [], '(a) – performs a logarithm operation of a value and passes the result down the pipe, can use variable names, e.g. /log i', true, true); - registerSlashCommand('abs', (args, value) => absValuesCallback(args, value), [], '(a) – performs an absolute value operation of a value and passes the result down the pipe, can use variable names, e.g. /abs i', true, true); - registerSlashCommand('sqrt', (args, value) => sqrtValuesCallback(args, value), [], '(a) – performs a square root operation of a value and passes the result down the pipe, can use variable names, e.g. /sqrt i', true, true); - registerSlashCommand('round', (args, value) => roundValuesCallback(args, value), [], '(a) – rounds a value and passes the result down the pipe, can use variable names, e.g. /round i', true, true); - registerSlashCommand('len', (_, value) => lenValuesCallback(value), [], '(a) – gets the length of a value and passes the result down the pipe, can use variable names, e.g. /len i', true, true); - registerSlashCommand('rand', (args, value) => randValuesCallback(Number(args.from ?? 0), Number(args.to ?? (value.length ? value : 1)), args), [], '(from=number=0 to=number=1 round=round|ceil|floor) – returns a random number between from and to, e.g. /rand or /rand 10 or /rand from=5 to=10', true, true); - registerSlashCommand('var', (args, value) => varCallback(args, value), [], '[optional index] (variableName) (optional variable value) – Get or set a variable. Example: /let x foo | /var x foo bar | /var x | /echo', true, true); - registerSlashCommand('let', (args, value) => letCallback(args, value), [], '(variableName) (optional variable value) – Declares a new variable in the current scope. Example: /let x foo bar | /echo {{var::x}} or /let y', true, true); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'listvar', + callback: listVariablesCallback, + helpString: 'List registered chat variables.', + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'setvar', + callback: (args, value) => setLocalVariable(args.key || args.name, value, args), + returns: 'the set variable value', + namedArgumentList: [ + new SlashCommandNamedArgument( + 'key', 'variable name', [ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + new SlashCommandNamedArgument( + 'index', 'list index', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], false, + ), + ], + unnamedArgumentList: [ + new SlashCommandArgument( + 'value', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY], true, + ), + ], + helpString: ` +
+ Set a local variable value and pass it down the pipe. The index argument is optional. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'getvar', + callback: (args, value) => getLocalVariable(value, args), + returns: 'the variable value', + namedArgumentList: [ + new SlashCommandNamedArgument( + 'index', 'list index', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], false, + ), + ], + unnamedArgumentList: [ + new SlashCommandArgument( + 'key', [ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Get a local variable value and pass it down the pipe. The index argument is optional. +
+
+ Examples: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'addvar', + callback: (args, value) => addLocalVariable(args.key || args.name, value), + returns: 'the new variable value', + namedArgumentList: [ + new SlashCommandNamedArgument( + 'key', 'variable name', [ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + unnamedArgumentList: [ + new SlashCommandArgument( + 'value to add to the variable', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], true, + ), + ], + helpString: ` +
+ Add a value to a local variable and pass the result down the pipe. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'setglobalvar', + callback: (args, value) => setGlobalVariable(args.key || args.name, value, args), + returns: 'the set global variable value', + namedArgumentList: [ + new SlashCommandNamedArgument( + 'key', 'variable name', [ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + new SlashCommandNamedArgument( + 'index', 'list index', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], false, + ), + ], + unnamedArgumentList: [ + new SlashCommandArgument( + 'value', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY], true, + ), + ], + helpString: ` +
+ Set a global variable value and pass it down the pipe. The index argument is optional. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'getglobalvar', + callback: (args, value) => getGlobalVariable(value, args), + returns: 'global variable value', + namedArgumentList: [ + new SlashCommandNamedArgument( + 'index', 'list index', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], false, + ), + ], + unnamedArgumentList: [ + new SlashCommandArgument( + 'key', [ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Get a global variable value and pass it down the pipe. The index argument is optional. +
+
+ Examples: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'addglobalvar', + callback: (args, value) => addGlobalVariable(args.key || args.name, value), + returns: 'the new variable value', + namedArgumentList: [ + new SlashCommandNamedArgument( + 'key', 'variable name', [ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + unnamedArgumentList: [ + new SlashCommandArgument( + 'value to add to the variable', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], true, + ), + ], + helpString: ` +
+ Add a value to a global variable and pass the result down the pipe. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'incvar', + callback: (_, value) => incrementLocalVariable(value), + returns: 'the new variable value', + unnamedArgumentList: [ + new SlashCommandArgument( + 'key', [ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Increment a local variable by 1 and pass the result down the pipe. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'decvar', + callback: (_, value) => decrementLocalVariable(value), + returns: 'the new variable value', + unnamedArgumentList: [ + new SlashCommandArgument( + 'key', [ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Decrement a local variable by 1 and pass the result down the pipe. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'incglobalvar', + callback: (_, value) => incrementGlobalVariable(value), + returns: 'the new variable value', + unnamedArgumentList: [ + new SlashCommandArgument( + 'key', [ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Increment a global variable by 1 and pass the result down the pipe. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'decglobalvar', + callback: (_, value) => decrementGlobalVariable(value), + returns: 'the new variable value', + unnamedArgumentList: [ + new SlashCommandArgument( + 'key', [ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Decrement a global variable by 1 and pass the result down the pipe. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'if', + callback: ifCallback, + returns: 'result of the executed command ("then" or "else")', + namedArgumentList: [ + new SlashCommandNamedArgument( + 'left', 'left operand', [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER], true, + ), + new SlashCommandNamedArgument( + 'right', 'right operand', [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER], true, + ), + new SlashCommandNamedArgument( + 'rule', 'comparison rule', [ARGUMENT_TYPE.STRING], true, false, null, ['gt', 'gte', 'lt', 'lte', 'eq', 'neq', 'not', 'in', 'nin'], + ), + new SlashCommandNamedArgument( + 'else', 'command to execute if not true', [ARGUMENT_TYPE.CLOSURE, ARGUMENT_TYPE.SUBCOMMAND], false, + ), + ], + unnamedArgumentList: [ + new SlashCommandArgument( + 'command to execute if true', [ARGUMENT_TYPE.CLOSURE, ARGUMENT_TYPE.SUBCOMMAND], true, + ), + ], + helpString: ` +
+ Compares the value of the left operand a with the value of the right operand b, + and if the condition yields true, then execute any valid slash command enclosed in quotes and pass the + result of the command execution down the pipe. +
+
+ Numeric values and string literals for left and right operands supported. +
+
+ Available rules: + +
+
+ Examples: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'while', + callback: whileCallback, + returns: 'result of the last executed command', + namedArgumentList: [ + new SlashCommandNamedArgument( + 'left', 'left operand', [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER], true, + ), + new SlashCommandNamedArgument( + 'right', 'right operand', [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER], true, + ), + new SlashCommandNamedArgument( + 'rule', 'comparison rule', [ARGUMENT_TYPE.STRING], true, false, null, ['gt', 'gte', 'lt', 'lte', 'eq', 'neq', 'not', 'in', 'nin'], + ), + new SlashCommandNamedArgument( + 'guard', 'disable loop iteration limit', [ARGUMENT_TYPE.STRING], false, false, null, ['off'], + ), + ], + unnamedArgumentList: [ + new SlashCommandArgument( + 'command to execute while true', [ARGUMENT_TYPE.CLOSURE, ARGUMENT_TYPE.SUBCOMMAND], true, + ), + ], + helpString: ` +
+ Compares the value of the left operand a with the value of the right operand b, + and if the condition yields true, then execute any valid slash command enclosed in quotes. +
+
+ Numeric values and string literals for left and right operands supported. +
+
+ Available rules: + +
+
+ Examples: + +
+
+ Loops are limited to 100 iterations by default, pass guard=off to disable. +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'times', + callback: timesCallback, + returns: 'result of the last executed command', + namedArgumentList: [], + unnamedArgumentList: [ + new SlashCommandArgument( + 'repeats', + [ARGUMENT_TYPE.NUMBER], + true, + ), + new SlashCommandArgument( + 'command', + [ARGUMENT_TYPE.CLOSURE, ARGUMENT_TYPE.SUBCOMMAND], + true, + ), + ], + helpString: ` +
+ Execute any valid slash command enclosed in quotes repeats number of times. +
+
+ Examples: + +
+
+ Loops are limited to 100 iterations by default, pass guard=off to disable. +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'flushvar', + callback: (_, value) => deleteLocalVariable(value), + namedArgumentList: [], + unnamedArgumentList: [ + new SlashCommandArgument( + 'key', [ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Delete a local variable. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'flushglobalvar', + callback: (_, value) => deleteGlobalVariable(value), + namedArgumentList: [], + unnamedArgumentList: [ + new SlashCommandArgument( + 'key', [ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Deletes the specified global variable. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'add', + callback: addValuesCallback, + returns: 'sum of the provided values', + unnamedArgumentList: [ + new SlashCommandArgument( + 'values', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, true, + ), + ], + helpString: ` +
+ Performs an addition of the set of values and passes the result down the pipe. + Can use variable names. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'mul', + callback: (args, value) => mulValuesCallback(args, value), + result: 'product of the provided values', + unnamedArgumentList: [ + new SlashCommandArgument( + 'values to multiply', + [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], + true, + true, + ), + ], + helpString: ` +
+ Performs a multiplication of the set of values and passes the result down the pipe. Can use variable names. +
+
+ Examples: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'max', + callback: maxValuesCallback, + returns: 'maximum value of the set of values', + unnamedArgumentList: [ + new SlashCommandArgument( + 'values', + [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], + true, + true, + ), + ], + helpString: ` +
+ Returns the maximum value of the set of values and passes the result down the pipe. Can use variable names. +
+
+ Examples: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'min', + callback: minValuesCallback, + returns: 'minimum value of the set of values', + unnamedArgumentList: [ + new SlashCommandArgument( + 'values', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, true, + ), + ], + helpString: ` +
+ Returns the minimum value of the set of values and passes the result down the pipe. + Can use variable names. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'sub', + callback: subValuesCallback, + returns: 'difference of the provided values', + unnamedArgumentList: [ + new SlashCommandArgument( + 'values', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, true, + ), + ], + helpString: ` +
+ Performs a subtraction of the set of values and passes the result down the pipe. + Can use variable names. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'div', + callback: divValuesCallback, + returns: 'result of division', + unnamedArgumentList: [ + new SlashCommandArgument( + 'dividend', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + new SlashCommandArgument( + 'divisor', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Performs a division of two values and passes the result down the pipe. + Can use variable names. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'mod', + callback: modValuesCallback, + returns: 'result of modulo operation', + unnamedArgumentList: [ + new SlashCommandArgument( + 'dividend', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + new SlashCommandArgument( + 'divisor', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Performs a modulo operation of two values and passes the result down the pipe. + Can use variable names. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'pow', + callback: powValuesCallback, + returns: 'result of power operation', + unnamedArgumentList: [ + new SlashCommandArgument( + 'base', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + new SlashCommandArgument( + 'exponent', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Performs a power operation of two values and passes the result down the pipe. + Can use variable names. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'sin', + callback: sinValuesCallback, + returns: 'sine of the provided value', + unnamedArgumentList: [ + new SlashCommandArgument( + 'value', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Performs a sine operation of a value and passes the result down the pipe. + Can use variable names. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'cos', + callback: cosValuesCallback, + returns: 'cosine of the provided value', + unnamedArgumentList: [ + new SlashCommandArgument( + 'value', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Performs a cosine operation of a value and passes the result down the pipe. + Can use variable names. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'log', + callback: logValuesCallback, + returns: 'log of the provided value', + namedArgumentList: [], + unnamedArgumentList: [ + new SlashCommandArgument( + 'value', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Performs a logarithm operation of a value and passes the result down the pipe. + Can use variable names. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'abs', + callback: absValuesCallback, + returns: 'absolute value of the provided value', + unnamedArgumentList: [ + new SlashCommandArgument( + 'value', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Performs an absolute value operation of a value and passes the result down the pipe. + Can use variable names. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'sqrt', + callback: sqrtValuesCallback, + returns: 'square root of the provided value', + unnamedArgumentList: [ + new SlashCommandArgument( + 'value', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Performs a square root operation of a value and passes the result down the pipe. + Can use variable names. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'round', + callback: roundValuesCallback, + returns: 'rounded value', + unnamedArgumentList: [ + new SlashCommandArgument( + 'value', [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + ], + helpString: ` +
+ Rounds a value and passes the result down the pipe. + Can use variable names. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'len', + callback: (_, value) => lenValuesCallback(value), + returns: 'length of the provided value', + unnamedArgumentList: [ + new SlashCommandArgument( + 'value', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.VARIABLE_NAME], true + ), + ], + helpString: ` +
+ Gets the length of a value and passes the result down the pipe. Can use variable names. +
+
+ Example: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'rand', + callback: (args, value) => randValuesCallback(Number(args.from ?? 0), Number(args.to ?? (value.length ? value : 1)), args), + returns: 'random number', + namedArgumentList: [ + new SlashCommandNamedArgument( + 'from', + 'starting value for the range (inclusive)', + [ARGUMENT_TYPE.NUMBER], + false, + false, + '0', + ), + new SlashCommandNamedArgument( + 'to', + 'ending value for the range (inclusive)', + [ARGUMENT_TYPE.NUMBER], + false, + false, + '1', + ), + new SlashCommandNamedArgument( + 'round', + 'rounding method for the result', + [ARGUMENT_TYPE.STRING], + false, + false, + null, + ['round', 'ceil', 'floor'], + ), + ], + helpString: ` +
+ Returns a random number between from and to (inclusive). +
+
+ Examples: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'var', + callback: (args, value) => varCallback(args, value), + returns: 'the variable value', + namedArgumentList: [ + new SlashCommandNamedArgument( + 'index', + 'optional index for list or dictionary', + [ARGUMENT_TYPE.NUMBER], + false, // isRequired + false, // acceptsMultiple + ), + ], + unnamedArgumentList: [ + new SlashCommandArgument( + 'variable name', + [ARGUMENT_TYPE.VARIABLE_NAME], + true, // isRequired + false, // acceptsMultiple + ), + new SlashCommandArgument( + 'variable value', + [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY, ARGUMENT_TYPE.CLOSURE], + false, // isRequired + false, // acceptsMultiple + ), + ], + helpString: ` +
+ Get or set a variable. +
+
+ Examples: + +
+ `, + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'let', + callback: (args, value) => letCallback(args, value), + returns: 'the variable value', + namedArgumentList: [], + unnamedArgumentList: [ + new SlashCommandArgument( + 'variable name', [ARGUMENT_TYPE.VARIABLE_NAME], true, + ), + new SlashCommandArgument( + 'variable value', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY, ARGUMENT_TYPE.CLOSURE], + ), + ], + helpString: ` +
+ Declares a new variable in the current scope. +
+
+ Examples: + +
+ `, + })); }