diff options
Diffstat (limited to 'src/hypixel.ts')
-rw-r--r-- | src/hypixel.ts | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/hypixel.ts b/src/hypixel.ts index a9a0233..285ac4e 100644 --- a/src/hypixel.ts +++ b/src/hypixel.ts @@ -129,8 +129,8 @@ export async function fetchUser({ user, uuid, username }: UserAny, included: Inc if (includeProfiles) { for (const profile of profilesData!) { const member = profile.members?.find(member => member.uuid === uuid) - if (member && member.last_save > lastOnline) { - lastOnline = member.last_save + if (member && member.lastSave > lastOnline) { + lastOnline = member.lastSave activeProfile = profile } } @@ -167,11 +167,12 @@ export async function fetchMemberProfile(user: string, profile: string, customiz if (!profileUuid) return null if (!playerUuid) return null - const player = await cached.fetchPlayer(playerUuid) + const player: CleanPlayer | null = await cached.fetchPlayer(playerUuid) if (!player) return null // this should never happen, but if it does just return null - const cleanProfile = await cached.fetchProfile(playerUuid, profileUuid) as CleanFullProfileBasicMembers + const cleanProfile = await cached.fetchProfile(playerUuid, profileUuid) + if (!cleanProfile) return null const member = cleanProfile.members.find(m => m.uuid === playerUuid) if (!member) return null // this should never happen, but if it does just return null @@ -181,13 +182,16 @@ export async function fetchMemberProfile(user: string, profile: string, customiz return { uuid: m.uuid, username: m.username, - first_join: m.first_join, - last_save: m.last_save, + firstJoin: m.firstJoin, + lastSave: m.lastSave, rank: m.rank } }) - cleanProfile.members = simpleMembers + const cleanProfileBasicMembers: CleanFullProfileBasicMembers = { + ...cleanProfile, + members: simpleMembers + } let websiteAccount: WithId<AccountSchema> | null = null @@ -203,7 +207,7 @@ export async function fetchMemberProfile(user: string, profile: string, customiz // add all other data relating to the hypixel player, such as username, rank, etc ...player }, - profile: cleanProfile, + profile: cleanProfileBasicMembers, customization: websiteAccount?.customization } } @@ -301,7 +305,7 @@ export async function fetchElection(): Promise<ElectionData> { cachedElectionData = election // updates every 10 minutes - nextElectionUpdate = new Date((election.last_updated + 10 * 60) * 1000) + nextElectionUpdate = new Date((election.lastUpdated + 10 * 60) * 1000) return election } |