aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cleaners/skyblock/member.ts16
-rw-r--r--src/database.ts11
-rw-r--r--src/hypixel.ts2
3 files changed, 18 insertions, 11 deletions
diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts
index 2acbd26..c7c9a2e 100644
--- a/src/cleaners/skyblock/member.ts
+++ b/src/cleaners/skyblock/member.ts
@@ -22,8 +22,8 @@ import { CleanRank } from '../rank.js'
export interface CleanBasicMember {
uuid: string
username: string
- lastSave: number
- firstJoin: number
+ lastSave: number | null
+ firstJoin: number | null
rank: CleanRank
left?: boolean
}
@@ -53,8 +53,8 @@ export async function cleanSkyBlockProfileMemberResponseBasic(member: typedHypix
return {
uuid: member.uuid,
username: player.username,
- lastSave: member.last_save ?? 0,
- firstJoin: member.first_join ?? 0,
+ lastSave: member.last_save ?? null,
+ firstJoin: member.first_join ?? null,
rank: player.rank
}
}
@@ -74,8 +74,8 @@ export async function cleanSkyBlockProfileMemberResponse(member: typedHypixelApi
uuid: member.uuid,
username: player.username,
// members that haven't joined the profile have no last save or first join
- lastSave: member.last_save ?? 0,
- firstJoin: member.first_join ?? 0,
+ lastSave: member.last_save ?? null,
+ firstJoin: member.first_join ?? null,
rank: player.rank,
purse: member.coin_purse ?? 0,
@@ -105,8 +105,8 @@ export async function cleanSkyBlockProfileMemberResponse(member: typedHypixelApi
export interface CleanMemberProfilePlayer extends CleanPlayer {
// The profile name may be different for each player, so we put it here
profileName: string
- firstJoin: number
- lastSave: number
+ firstJoin: number | null
+ lastSave: number | null
purse: number
stats: StatItem[]
rawHypixelStats: { [key: string]: number }
diff --git a/src/database.ts b/src/database.ts
index 1702a20..8f0ce0a 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -185,7 +185,7 @@ function getMemberHarpAttributes(member: CleanMember): StringNumber {
function getMemberLeaderboardAttributes(member: CleanMember): StringNumber {
// if you want to add a new leaderboard for member attributes, add it here (and getAllLeaderboardAttributes)
- return {
+ const data: StringNumber = {
// we use the raw stat names rather than the clean stats in case hypixel adds a new stat and it takes a while for us to clean it
...member.rawHypixelStats,
@@ -202,10 +202,16 @@ function getMemberLeaderboardAttributes(member: CleanMember): StringNumber {
...getMemberHarpAttributes(member),
fairy_souls: member.fairySouls.total,
- first_join: member.firstJoin,
purse: member.purse,
visited_zones: member.zones.filter(z => z.visited).length,
}
+
+ if (member.firstJoin)
+ data.first_join = member.firstJoin
+ if (member.lastSave)
+ data.last_save = member.lastSave
+
+ return data
}
function getProfileLeaderboardAttributes(profile: CleanFullProfile): StringNumber {
@@ -290,6 +296,7 @@ export async function fetchAllMemberLeaderboardAttributes(): Promise<string[]> {
'fairy_souls',
'first_join',
+ 'last_save',
'purse',
'visited_zones',
'leaderboards_count',
diff --git a/src/hypixel.ts b/src/hypixel.ts
index 4afac53..30a9f9b 100644
--- a/src/hypixel.ts
+++ b/src/hypixel.ts
@@ -135,7 +135,7 @@ 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.lastSave > lastOnline) {
+ if (member && member.lastSave && member.lastSave > lastOnline) {
lastOnline = member.lastSave
activeProfile = profile
}