add closure support to /run

This commit is contained in:
LenAnderson 2024-07-05 18:04:33 -04:00
parent 1ab11cf85f
commit 12e30bde99
1 changed files with 5 additions and 1 deletions

View File

@ -1075,7 +1075,7 @@ export function initDefaultSlashCommands() {
unnamedArgumentList: [
SlashCommandArgument.fromProps({
description: 'scoped variable or qr label',
typeList: [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING],
typeList: [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.CLOSURE],
isRequired: true,
enumProvider: () => [
...commonEnumProviders.variables('scope')(),
@ -1775,6 +1775,10 @@ async function runCallback(args, name) {
throw new Error('No name provided for /run command');
}
if (name instanceof SlashCommandClosure) {
return await name.execute();
}
/**@type {SlashCommandScope} */
const scope = args._scope;
if (scope.existsVariable(name)) {