#2832 /ask text non-required
| @@ -440,7 +440,7 @@ export function initDefaultSlashCommands() { | ||
| 440 | 440 | ], |
| 441 | 441 | unnamedArgumentList: [ |
| 442 | 442 | new SlashCommandArgument( |
| 443 | 443 | 'prompt', [ARGUMENT_TYPE.STRING], truefalse, false, |
| 444 | 444 | ), |
| 445 | 445 | ], |
| 446 | 446 | helpString: 'Asks a specified character card a prompt. Character name must be provided in a named argument.', |
| @@ -2469,31 +2469,21 @@ async function askCharacter(args, text) { | ||
| 2469 | 2469 | // Not supported in group chats |
| 2470 | 2470 | // TODO: Maybe support group chats? |
| 2471 | 2471 | if (selected_group) { |
| 2472 | 2472 | toastr.error('Cannot run this/ask command in a group chat!'); |
| 2473 | - return ''; | |
| 2474 | - } | |
| 2475 | - | |
| 2476 | - if (!text) { | |
| 2477 | - console.warn('WARN: No text provided for /ask command'); | |
| 2478 | - toastr.warning('No text provided for /ask command'); | |
| 2479 | 2473 | return ''; |
| 2480 | 2474 | } |
| 2481 | 2475 | |
| 2482 | 2476 | let name = ''; |
| 2483 | - let mesText = ''; | |
| 2484 | 2477 | |
| 2485 | 2478 | if (args?.name) { |
| 2486 | 2479 | name = args.name.trim(); |
| 2487 | - mesText = text.trim(); | |
| 2488 | 2480 | |
| 2489 | 2481 | if (!name && !mesText) { |
| 2490 | 2482 | toastr.warning('You must specify a name andof textthe character to ask.'); |
| 2491 | 2483 | return ''; |
| 2492 | 2484 | } |
| 2493 | 2485 | } |
| 2494 | 2486 | |
| 2495 | - mesText = getRegexedString(mesText, regex_placement.SLASH_COMMAND); | |
| 2496 | - | |
| 2497 | 2487 | const prevChId = this_chid; |
| 2498 | 2488 | |
| 2499 | 2489 | // Find the character |
| @@ -2503,9 +2493,12 @@ async function askCharacter(args, text) { | ||
| 2503 | 2493 | return ''; |
| 2504 | 2494 | } |
| 2505 | 2495 | |
| 2496 | + if (text) { | |
| 2497 | + const mesText = getRegexedString(text.trim(), regex_placement.SLASH_COMMAND); | |
| 2506 | 2498 | // Sending a message implicitly saves the chat, so this needs to be done before changing the character |
| 2507 | 2499 | // Otherwise, a corruption will occur |
| 2508 | 2500 | await sendMessageAsUser(mesText, ''); |
| 2501 | + } | |
| 2509 | 2502 | |
| 2510 | 2503 | // Override character and send a user message |
| 2511 | 2504 | setCharacterId(String(chId)); |