use root AbortController in /if subcommands

This commit is contained in:
LenAnderson 2024-05-19 06:26:16 -04:00
parent dfe482b37b
commit 974d27ce26
1 changed files with 6 additions and 3 deletions

View File

@ -417,15 +417,18 @@ async function ifCallback(args, command) {
let commandResult; let commandResult;
if (result && command) { if (result && command) {
if (command instanceof SlashCommandClosure) return (await command.execute()).pipe; if (command instanceof SlashCommandClosure) return (await command.execute()).pipe;
commandResult = await executeSubCommands(command, args._scope, args._parserFlags); commandResult = await executeSubCommands(command, args._scope, args._parserFlags, args._abortController);
} else if (!result && args.else && ((typeof args.else === 'string' && args.else !== '') || args.else instanceof SlashCommandClosure)) { } else if (!result && args.else && ((typeof args.else === 'string' && args.else !== '') || args.else instanceof SlashCommandClosure)) {
if (args.else instanceof SlashCommandClosure) return (await args.else.execute(args._scope)).pipe; if (args.else instanceof SlashCommandClosure) return (await args.else.execute(args._scope)).pipe;
commandResult = await executeSubCommands(args.else, args._scope, args._parserFlags); commandResult = await executeSubCommands(args.else, args._scope, args._parserFlags, args._abortController);
} }
// this is only reached by subcommands, not by closures, so this is fine
if (commandResult) { if (commandResult) {
if (commandResult.isAborted) { if (commandResult.isAborted) {
args._abortController.abort(commandResult.abortReason, true); // abort toast (if loud) is already shown in subcommand execution,
// overwrite signal to quiet to prevent second toast from ancestor executions
args._abortController.signal.isQuiet = true;
} }
return commandResult.pipe; return commandResult.pipe;
} }