#1781 Fix /len and unescape for non-string arguments

This commit is contained in:
Cohee
2024-02-03 02:06:49 +02:00
parent 37d94a4331
commit 07677584c4
2 changed files with 30 additions and 13 deletions

View File

@ -1561,21 +1561,26 @@ async function executeSlashCommands(text, unescape = false) {
}
}
if (typeof unnamedArg === 'string' && /{{pipe}}/i.test(unnamedArg)) {
unnamedArg = unnamedArg.replace(/{{pipe}}/i, pipeResult ?? '');
if (typeof unnamedArg === 'string') {
if (/{{pipe}}/i.test(unnamedArg)) {
unnamedArg = unnamedArg.replace(/{{pipe}}/i, pipeResult ?? '');
}
unnamedArg = unnamedArg
?.replace(/\\\|/g, '|')
?.replace(/\\\{/g, '{')
?.replace(/\\\}/g, '}')
;
}
unnamedArg = unnamedArg
?.replace(/\\\|/g, '|')
?.replace(/\\\{/g, '{')
?.replace(/\\\}/g, '}')
;
for (const [key, value] of Object.entries(result.args)) {
result.args[key] = value
.replace(/\\\|/g, '|')
.replace(/\\\{/g, '{')
.replace(/\\\}/g, '}')
;
if (typeof value === 'string') {
result.args[key] = value
.replace(/\\\|/g, '|')
.replace(/\\\{/g, '{')
.replace(/\\\}/g, '}')
;
}
}
pipeResult = await result.command.callback(result.args, unnamedArg);