Update /ask with return types, defaulting 'pipe'

This commit is contained in:
Wolfsblvt 2024-09-30 23:37:21 +02:00
parent d8379edee7
commit e3c0c5442c
1 changed files with 12 additions and 2 deletions

View File

@ -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) {