Fix /ask corruption + add return value Fixes #2832 and a skill issue

2379fd59706c52f6d652607f022995d14a7da28a

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

1 files changed, +8 -4Ignore whitespace
public/scripts/slash-commands.js+8 -4
@@ -428,6 +428,7 @@ export function initDefaultSlashCommands() {
428 SlashCommandParser.addCommandObject(SlashCommand.fromProps({428 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
429 name: 'ask',429 name: 'ask',
430 callback: askCharacter,430 callback: askCharacter,
431 returns: 'the generated text',
431 namedArgumentList: [432 namedArgumentList: [
432 SlashCommandNamedArgument.fromProps({433 SlashCommandNamedArgument.fromProps({
433 name: 'name',434 name: 'name',
@@ -2535,22 +2536,25 @@ async function askCharacter(args, text) {
2535 }2536 }
2536 };2537 };
25372538
2539 let askResult = '';
2540
2538 // Run generate and restore previous character2541 // Run generate and restore previous character
2539 try {2542 try {
2540 toastr.info(`Asking ${character.name} something...`);2543 toastr.info(`Asking ${character.name} something...`);
2541 await Generate('ask_command');2544 askResult = await Generate('ask_command');
2542 await saveChatConditional();
2543 } catch (error) {2545 } catch (error) {
2544 console.error('Error running /ask command', error);2546 console.error('Error running /ask command', error);
2545 } finally {2547 } finally {
2546 restoreCharacter();2548 restoreCharacter();
25472549
2548 if (this_chid !== prevChId) {2550 if (this_chid === prevChId) {
2551 await saveChatConditional();
2552 } else {
2549 toastr.error('It is strongly recommended to reload the page.', 'Something went wrong');2553 toastr.error('It is strongly recommended to reload the page.', 'Something went wrong');
2550 }2554 }
2551 }2555 }
25522556
2553 return '';2557 return askResult;
2554}2558}
25552559
2556async function hideMessageCallback(_, arg) {2560async function hideMessageCallback(_, arg) {