#2832 /ask text non-required

81cd38d4f70bfbb31641618382afd6d0d8df99aa

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +10 -17Ignore whitespace
public/scripts/slash-commands.js+10 -17
@@ -440,7 +440,7 @@ export function initDefaultSlashCommands() {
440440 ],
441441 unnamedArgumentList: [
442442 new SlashCommandArgument(
443443 'prompt', [ARGUMENT_TYPE.STRING], truefalse, false,
444444 ),
445445 ],
446446 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) {
24692469 // Not supported in group chats
24702470 // TODO: Maybe support group chats?
24712471 if (selected_group) {
24722472 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');
24792473 return '';
24802474 }
24812475
24822476 let name = '';
2483- let mesText = '';
24842477
24852478 if (args?.name) {
24862479 name = args.name.trim();
2487- mesText = text.trim();
24882480
24892481 if (!name && !mesText) {
24902482 toastr.warning('You must specify a name andof textthe character to ask.');
24912483 return '';
24922484 }
24932485 }
24942486
2495- mesText = getRegexedString(mesText, regex_placement.SLASH_COMMAND);
2496-
24972487 const prevChId = this_chid;
24982488
24992489 // Find the character
@@ -2503,9 +2493,12 @@ async function askCharacter(args, text) {
25032493 return '';
25042494 }
25052495
2506- // Sending a message implicitly saves the chat, so this needs to be done before changing the character
2496+ if (text) {
2507- // Otherwise, a corruption will occur
2497+ const mesText = getRegexedString(text.trim(), regex_placement.SLASH_COMMAND);
2508- await sendMessageAsUser(mesText, '');
2498+ // Sending a message implicitly saves the chat, so this needs to be done before changing the character
2499+ // Otherwise, a corruption will occur
2500+ await sendMessageAsUser(mesText, '');
2501+ }
25092502
25102503 // Override character and send a user message
25112504 setCharacterId(String(chId));