diff --git a/public/scripts/slash-commands/SlashCommandScope.js b/public/scripts/slash-commands/SlashCommandScope.js index 30e545429..78edb78ae 100644 --- a/public/scripts/slash-commands/SlashCommandScope.js +++ b/public/scripts/slash-commands/SlashCommandScope.js @@ -97,7 +97,7 @@ export class SlashCommandScope { return v ?? ''; } else { const value = this.variables[key]; - return (value === '' || isNaN(Number(value))) ? (value || '') : Number(value); + return (value?.trim?.() === '' || isNaN(Number(value))) ? (value || '') : Number(value); } } if (this.parent) { diff --git a/public/scripts/variables.js b/public/scripts/variables.js index 4e968293f..709dfb9b1 100644 --- a/public/scripts/variables.js +++ b/public/scripts/variables.js @@ -41,7 +41,7 @@ function getLocalVariable(name, args = {}) { } } - return (localVariable === '' || isNaN(Number(localVariable))) ? (localVariable || '') : Number(localVariable); + return (localVariable?.trim?.() === '' || isNaN(Number(localVariable))) ? (localVariable || '') : Number(localVariable); } function setLocalVariable(name, value, args = {}) { @@ -94,7 +94,7 @@ function getGlobalVariable(name, args = {}) { } } - return (globalVariable === '' || isNaN(Number(globalVariable))) ? (globalVariable || '') : Number(globalVariable); + return (globalVariable?.trim?.() === '' || isNaN(Number(globalVariable))) ? (globalVariable || '') : Number(globalVariable); } function setGlobalVariable(name, value, args = {}) {