diff --git a/public/scripts/variables.js b/public/scripts/variables.js index d41a9785f..04ca9b146 100644 --- a/public/scripts/variables.js +++ b/public/scripts/variables.js @@ -740,6 +740,10 @@ export function registerVariableCommands() { 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) => { + if (Array.isArray(value)) { + args._scope.setVariable(value[0], value[1]); + return value[1]; + } if (value.includes(' ')) { const key = value.split(' ')[0]; const val = value.split(' ').slice(1).join(' '); @@ -749,6 +753,10 @@ export function registerVariableCommands() { return args._scope.getVariable(value, args.index); }, [], '[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) => { + if (Array.isArray(value)) { + args._scope.letVariable(value[0], value[1]); + return value[1]; + } if (value.includes(' ')) { const key = value.split(' ')[0]; const val = value.split(' ').slice(1).join(' ');