From 9f213e9e8c1022ce4e2aaf3ea4ebbd35f39f69a2 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sat, 6 May 2023 03:17:43 -0500 Subject: [PATCH] refactor: fold switch case --- src/core/functions.ts | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/core/functions.ts b/src/core/functions.ts index 121cac2..625e334 100644 --- a/src/core/functions.ts +++ b/src/core/functions.ts @@ -36,29 +36,23 @@ export function treeSearch( const cur = _options.pop()!; switch (cur.type) { case ApplicationCommandOptionType.Subcommand: - { + case ApplicationCommandOptionType.SubcommandGroup: + { for (const option of cur.options ?? []) { _options.push(option); } - } - break; - case ApplicationCommandOptionType.SubcommandGroup: - { - for (const command of cur.options ?? []) { - _options.push(command); - } - } - break; + } + break; default: - { - if (cur.autocomplete) { - const choice = iAutocomplete.options.getFocused(true); - if (cur.name === choice.name && cur.autocomplete) { - autocompleteData = cur; - } + { + if (cur.autocomplete) { + const choice = iAutocomplete.options.getFocused(true); + if (cur.name === choice.name && cur.autocomplete) { + autocompleteData = cur; } } - break; + } + break; } } return autocompleteData;