Skip to content

Commit

Permalink
Add ability to wipe all bank weights (#5741)
Browse files Browse the repository at this point in the history
  • Loading branch information
themrrobert authored Mar 1, 2024
1 parent 6078da7 commit 860c057
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/mahoji/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.';
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
]
},
Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 860c057

Please sign in to comment.