From 860c05704fc4482e347d57957c5edaa468c2f066 Mon Sep 17 00:00:00 2001 From: themrrobert <10122432+themrrobert@users.noreply.github.com> Date: Fri, 1 Mar 2024 11:55:49 -0800 Subject: [PATCH] Add ability to wipe all bank weights (#5741) --- src/mahoji/commands/config.ts | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/mahoji/commands/config.ts b/src/mahoji/commands/config.ts index c30216dd6e..7b8b2664e1 100644 --- a/src/mahoji/commands/config.ts +++ b/src/mahoji/commands/config.ts @@ -313,7 +313,8 @@ async function bankSortConfig( user: MUser, sortMethod: string | undefined, addWeightingBank: string | undefined, - removeWeightingBank: string | undefined + removeWeightingBank: string | undefined, + resetWeightingBank: string | undefined ): CommandResponse { const currentMethod = user.user.bank_sort_method; const currentWeightingBank = new Bank(user.user.bank_sort_weightings as ItemBank); @@ -323,7 +324,7 @@ async function bankSortConfig( return patronMsg(PerkTier.Two); } - if (!sortMethod && !addWeightingBank && !removeWeightingBank) { + if (!sortMethod && !addWeightingBank && !removeWeightingBank && !resetWeightingBank) { const sortStr = currentMethod ? `Your current bank sort method is ${inlineCode(currentMethod)}.` : 'You have not set a bank sort method.'; @@ -367,12 +368,13 @@ async function bankSortConfig( if (addWeightingBank) newBank.add(inputBank); else if (removeWeightingBank) newBank.remove(inputBank); + else if (resetWeightingBank && resetWeightingBank === 'reset') newBank.bank = {}; await user.update({ bank_sort_weightings: newBank.bank }); - return bankSortConfig(await mUserFetch(user.id), undefined, undefined, undefined); + return bankSortConfig(await mUserFetch(user.id), undefined, undefined, undefined, undefined); } async function bgColorConfig(user: MUser, hex?: string) { @@ -924,6 +926,12 @@ export const configCommand: OSBMahojiCommand = { name: 'remove_weightings', description: "Remove weightings for extra bank sorting (e.g. '1 trout, 5 coal')", required: false + }, + { + type: ApplicationCommandOptionType.String, + name: 'reset_weightings', + description: "Type 'reset' to confirm you want to delete ALL of your bank weightings.", + required: false } ] }, @@ -1183,7 +1191,12 @@ LIMIT 20; combat_options?: { action: 'add' | 'remove' | 'list' | 'help'; input: string }; set_rsn?: { username: string }; bg_color?: { color?: string }; - bank_sort?: { sort_method?: string; add_weightings?: string; remove_weightings?: string }; + bank_sort?: { + sort_method?: string; + add_weightings?: string; + remove_weightings?: string; + reset_weightings?: string; + }; favorite_alchs?: { add?: string; remove?: string; add_many?: string; reset?: boolean }; favorite_food?: { add?: string; remove?: string; reset?: boolean }; favorite_items?: { add?: string; remove?: string; reset?: boolean }; @@ -1266,7 +1279,8 @@ LIMIT 20; user, bank_sort.sort_method, bank_sort.add_weightings, - bank_sort.remove_weightings + bank_sort.remove_weightings, + bank_sort.reset_weightings ); } if (favorite_alchs) {