aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cleaners/skyblock/coopInvitation.ts3
-rw-r--r--src/cleaners/skyblock/member.ts2
-rw-r--r--src/hypixelCached.ts10
3 files changed, 10 insertions, 5 deletions
diff --git a/src/cleaners/skyblock/coopInvitation.ts b/src/cleaners/skyblock/coopInvitation.ts
index 6aa8803..0188772 100644
--- a/src/cleaners/skyblock/coopInvitation.ts
+++ b/src/cleaners/skyblock/coopInvitation.ts
@@ -10,9 +10,10 @@ export interface CoopInvitation {
acceptedTimestamp: number | null
}
-export async function cleanCoopInvitation(data: typedHypixelApi.SkyBlockProfileMember): Promise<CoopInvitation | null> {
+export async function cleanCoopInvitation(data: typedHypixelApi.SkyBlockProfileMember, uuid: string): Promise<CoopInvitation | null> {
if (!data.coop_invitation)
return null
+
return {
invitedTimestamp: data.coop_invitation.timestamp,
invitedBy: await cached.fetchBasicPlayer(data.coop_invitation.invited_by, false),
diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts
index 9231456..014c147 100644
--- a/src/cleaners/skyblock/member.ts
+++ b/src/cleaners/skyblock/member.ts
@@ -72,7 +72,7 @@ export async function cleanSkyBlockProfileMemberResponse(member: typedHypixelApi
if (fairySouls.total > (maxFairySouls ?? 0))
await constants.setConstantValues({ max_fairy_souls: fairySouls.total })
- const coopInvitationPromise = cleanCoopInvitation(member)
+ const coopInvitationPromise = cleanCoopInvitation(member, member.uuid)
const minionsPromise = cleanMinions(member)
const skillsPromise = cleanSkills(member)
const zonesPromise = cleanVisitedZones(member)
diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts
index 3c703f6..a2600f2 100644
--- a/src/hypixelCached.ts
+++ b/src/hypixelCached.ts
@@ -313,6 +313,10 @@ export async function fetchProfileUuid(user: string, profile: string): Promise<s
if (!profiles) return null // user probably doesnt exist
const profileUuid = undashUuid(profile)
+ if (isUuid(profileUuid)) {
+ // if the profile is already a uuid, just return it
+ return profileUuid
+ }
for (const p of profiles) {
if (p.name?.toLowerCase() === profileUuid.toLowerCase())
@@ -411,11 +415,11 @@ export async function fetchProfileName(user: string, profile: string): Promise<s
if (!basicProfiles) return null
- let profileName: string | null = null
+ let profileName = profile // we default to the profile uuid provided
for (const basicProfile of basicProfiles)
- if (basicProfile.uuid === playerUuid)
- profileName = basicProfile.name ?? null
+ if (basicProfile.uuid === playerUuid && basicProfile.name)
+ profileName = basicProfile.name
profileNameCache.set(`${playerUuid}.${profileUuid}`, profileName)
return profileName