mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-12 09:26:33 +01:00
add closure support to /run
This commit is contained in:
parent
1ab11cf85f
commit
12e30bde99
@ -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)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user