mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-13 18:07:20 +01:00
87cc28ae28
- use AbortController in /abort instead of execption - allow quiet abort - allow loud abort - allow abort reason - abort when aborted in subcommand - break out of loops when aborted inside - fix parsing of subcommands with multiple commands
29 lines
781 B
JavaScript
29 lines
781 B
JavaScript
export class SlashCommandAbortController {
|
|
/**@type {SlashCommandAbortSignal}*/ signal;
|
|
|
|
|
|
constructor() {
|
|
this.signal = new SlashCommandAbortSignal();
|
|
}
|
|
abort(reason = 'No reason.', isQuiet = false) {
|
|
this.signal.isQuiet = isQuiet;
|
|
this.signal.aborted = true;
|
|
this.signal.reason = reason;
|
|
}
|
|
pause(reason = 'No reason.') {
|
|
this.signal.paused = true;
|
|
this.signal.reason = reason;
|
|
}
|
|
continue(reason = 'No reason.') {
|
|
this.signal.paused = false;
|
|
this.signal.reason = reason;
|
|
}
|
|
}
|
|
|
|
export class SlashCommandAbortSignal {
|
|
/**@type {boolean}*/ isQuiet = false;
|
|
/**@type {boolean}*/ paused = false;
|
|
/**@type {boolean}*/ aborted = false;
|
|
/**@type {string}*/ reason = null;
|
|
}
|