From e3c0c5442c1646970802cb1243bb9e39279d28be Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Mon, 30 Sep 2024 23:37:21 +0200 Subject: [PATCH] Update /ask with return types, defaulting 'pipe' --- public/scripts/slash-commands.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index 599d6b850..792e54bf1 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -456,7 +456,7 @@ export function initDefaultSlashCommands() { SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'ask', callback: askCharacter, - returns: 'the generated text', + returns: 'Optionally the text of the sent message, if specified in the "return" argument', namedArgumentList: [ SlashCommandNamedArgument.fromProps({ name: 'name', @@ -465,6 +465,14 @@ export function initDefaultSlashCommands() { isRequired: true, enumProvider: commonEnumProviders.characters('character'), }), + SlashCommandNamedArgument.fromProps({ + name: 'return', + description: 'The way how you want the return value to be provided', + typeList: [ARGUMENT_TYPE.STRING], + defaultValue: 'pipe', + enumList: slashCommandReturnHelper.enumList({ allowObject: true }), + forceEnum: true, + }), ], unnamedArgumentList: [ new SlashCommandArgument( @@ -2594,7 +2602,9 @@ async function askCharacter(args, text) { } } - return askResult; + const message = askResult ? chat[chat.length - 1] : null; + + return await slashCommandReturnHelper.doReturn(args.return ?? 'pipe', message, { objectToStringFunc: x => x.mes }); } async function hideMessageCallback(_, arg) {