Update /ask with return types, defaulting 'pipe'
| @@ -456,7 +456,7 @@ export function initDefaultSlashCommands() { | |||
| 456 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 456 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 457 | name: 'ask', | 457 | name: 'ask', |
| 458 | callback: askCharacter, | 458 | callback: askCharacter, |
| 459 | returns: 'the generated text', | 459 | returns: 'Optionally the text of the sent message, if specified in the "return" argument', |
| 460 | namedArgumentList: [ | 460 | namedArgumentList: [ |
| 461 | SlashCommandNamedArgument.fromProps({ | 461 | SlashCommandNamedArgument.fromProps({ |
| 462 | name: 'name', | 462 | name: 'name', |
| @@ -465,6 +465,14 @@ export function initDefaultSlashCommands() { | |||
| 465 | isRequired: true, | 465 | isRequired: true, |
| 466 | enumProvider: commonEnumProviders.characters('character'), | 466 | enumProvider: commonEnumProviders.characters('character'), |
| 467 | }), | 467 | }), |
| 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 | }), | ||
| 468 | ], | 476 | ], |
| 469 | unnamedArgumentList: [ | 477 | unnamedArgumentList: [ |
| 470 | new SlashCommandArgument( | 478 | new SlashCommandArgument( |
| @@ -2594,7 +2602,9 @@ async function askCharacter(args, text) { | |||
| 2594 | } | 2602 | } |
| 2595 | } | 2603 | } |
| 2596 | 2604 | ||
| 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 }); | ||
| 2598 | } | 2608 | } |
| 2599 | 2609 | ||
| 2600 | async function hideMessageCallback(_, arg) { | 2610 | async function hideMessageCallback(_, arg) { |