From 99cd99851de3a14faf7ac99732e8915c2e5da057 Mon Sep 17 00:00:00 2001 From: DayV Date: Mon, 25 Nov 2024 21:13:11 +0000 Subject: [PATCH 1/2] Allow clues to be repeated if in bank --- src/lib/util/repeatStoredTrip.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lib/util/repeatStoredTrip.ts b/src/lib/util/repeatStoredTrip.ts index ee5e56399be..6bee51fdc2d 100644 --- a/src/lib/util/repeatStoredTrip.ts +++ b/src/lib/util/repeatStoredTrip.ts @@ -5,6 +5,7 @@ import { ButtonBuilder, ButtonStyle } from 'discord.js'; import { Time } from 'e'; import { autocompleteMonsters } from '../../mahoji/commands/k'; +import { ClueTiers } from '../clues/clueTiers'; import type { PvMMethod } from '../constants'; import { SlayerActivityConstants } from '../minions/data/combatConstants'; import { darkAltarRunes } from '../minions/functions/darkAltarCommand'; @@ -67,10 +68,13 @@ import type { NightmareZoneActivityTaskOptions, UnderwaterAgilityThievingTaskOpt import getOSItem from './getOSItem'; import { interactionReply } from './interactionReply'; -const taskCanBeRepeated = (activity: Activity) => { +const taskCanBeRepeated = (activity: Activity, user: MUser) => { if (activity.type === activity_type_enum.ClueCompletion) { const realActivity = convertStoredActivityToFlatActivity(activity) as ClueActivityTaskOptions; - return realActivity.implingID !== undefined; + return ( + realActivity.implingID !== undefined || + user.owns(ClueTiers.find(mon => mon.id === realActivity.ci)!.scrollID) + ); } return !( [ @@ -90,7 +94,10 @@ const taskCanBeRepeated = (activity: Activity) => { const tripHandlers = { [activity_type_enum.ClueCompletion]: { commandName: 'clue', - args: (data: ClueActivityTaskOptions) => ({ tier: data.ci, implings: getOSItem(data.implingID!).name }) + args: (data: ClueActivityTaskOptions) => ({ + tier: data.ci, + implings: data.implingID ? getOSItem(data.implingID!).name : undefined + }) }, [activity_type_enum.SpecificQuest]: { commandName: 'm', @@ -692,8 +699,9 @@ export async function fetchRepeatTrips(userID: string) { type: activity_type_enum; data: Prisma.JsonValue; }[] = []; + const user = await mUserFetch(userID); for (const trip of res) { - if (!taskCanBeRepeated(trip)) continue; + if (!taskCanBeRepeated(trip, user)) continue; if (trip.type === activity_type_enum.Farming && !(trip.data as any as FarmingActivityTaskOptions).autoFarmed) { continue; } From d9a553f1b7e326abe256ef21efcdd363ef797b03 Mon Sep 17 00:00:00 2001 From: DayV Date: Mon, 25 Nov 2024 22:47:12 +0000 Subject: [PATCH 2/2] tidy --- src/lib/util/repeatStoredTrip.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/util/repeatStoredTrip.ts b/src/lib/util/repeatStoredTrip.ts index 6bee51fdc2d..2a2b7a98b39 100644 --- a/src/lib/util/repeatStoredTrip.ts +++ b/src/lib/util/repeatStoredTrip.ts @@ -73,7 +73,7 @@ const taskCanBeRepeated = (activity: Activity, user: MUser) => { const realActivity = convertStoredActivityToFlatActivity(activity) as ClueActivityTaskOptions; return ( realActivity.implingID !== undefined || - user.owns(ClueTiers.find(mon => mon.id === realActivity.ci)!.scrollID) + user.owns(ClueTiers.find(clue => clue.id === realActivity.ci)!.scrollID) ); } return !(