add closure support to /run

This commit is contained in:
LenAnderson 2024-07-05 18:04:33 -04:00
parent 1ab11cf85f
commit 12e30bde99

View File

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