Move macros replacement to script execution time

This commit is contained in:
Cohee
2023-11-24 01:56:43 +02:00
parent 461e8d7929
commit 74fbc88d7d
2 changed files with 20 additions and 10 deletions

View File

@ -86,7 +86,7 @@ class SlashCommandParser {
const key = match[1];
const value = match[2];
// Remove the quotes around the value, if any
argObj[key] = substituteParams(value.replace(/(^")|("$)/g, ''));
argObj[key] = value.replace(/(^")|("$)/g, '');
}
// Match unnamed argument
@ -1048,10 +1048,14 @@ async function executeSlashCommands(text, unescape = false) {
console.debug('Slash command executing:', result);
let unnamedArg = result.value || pipeResult;
if (pipeResult && typeof result.args === 'object') {
if (typeof result.args === 'object') {
for (const [key, value] of Object.entries(result.args)) {
if (typeof value === 'string' && /{{pipe}}/i.test(value)) {
result.args[key] = value.replace(/{{pipe}}/i, pipeResult);
if (typeof value === 'string') {
if (pipeResult && /{{pipe}}/i.test(value)) {
result.args[key] = value.replace(/{{pipe}}/i, pipeResult);
}
result.args[key] = substituteParams(value.trim());
}
}
}