Update /ask with return types, defaulting 'pipe'

e3c0c5442c1646970802cb1243bb9e39279d28be

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +12 -2Ignore whitespace
public/scripts/slash-commands.js+12 -2
@@ -456,7 +456,7 @@ export function initDefaultSlashCommands() {
456456 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
457457 name: 'ask',
458458 callback: askCharacter,
459- returns: 'the generated text',
459+ returns: 'Optionally the text of the sent message, if specified in the "return" argument',
460460 namedArgumentList: [
461461 SlashCommandNamedArgument.fromProps({
462462 name: 'name',
@@ -465,6 +465,14 @@ export function initDefaultSlashCommands() {
465465 isRequired: true,
466466 enumProvider: commonEnumProviders.characters('character'),
467467 }),
468+ SlashCommandNamedArgument.fromProps({
469+ name: 'return',
470+ description: 'The way how you want the return value to be provided',
471+ typeList: [ARGUMENT_TYPE.STRING],
472+ defaultValue: 'pipe',
473+ enumList: slashCommandReturnHelper.enumList({ allowObject: true }),
474+ forceEnum: true,
475+ }),
468476 ],
469477 unnamedArgumentList: [
470478 new SlashCommandArgument(
@@ -2594,7 +2602,9 @@ async function askCharacter(args, text) {
25942602 }
25952603 }
25962604
2597- return askResult;
2605+ const message = askResult ? chat[chat.length - 1] : null;
2606+
2607+ return await slashCommandReturnHelper.doReturn(args.return ?? 'pipe', message, { objectToStringFunc: x => x.mes });
25982608}
25992609
26002610async function hideMessageCallback(_, arg) {