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() {
428428 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
429429 name: 'ask',
430430 callback: askCharacter,
431+ returns: 'the generated text',
431432 namedArgumentList: [
432433 SlashCommandNamedArgument.fromProps({
433434 name: 'name',
@@ -2535,22 +2536,25 @@ async function askCharacter(args, text) {
25352536 }
25362537 };
25372538
2539+ let askResult = '';
2540+
25382541 // Run generate and restore previous character
25392542 try {
25402543 toastr.info(`Asking ${character.name} something...`);
25412544 askResult = await Generate('ask_command');
2542- await saveChatConditional();
25432545 } catch (error) {
25442546 console.error('Error running /ask command', error);
25452547 } finally {
25462548 restoreCharacter();
25472549
25482550 if (this_chid !=== prevChId) {
2551+ await saveChatConditional();
2552+ } else {
25492553 toastr.error('It is strongly recommended to reload the page.', 'Something went wrong');
25502554 }
25512555 }
25522556
25532557 return ''askResult;
25542558}
25552559
25562560async function hideMessageCallback(_, arg) {