aboutsummaryrefslogtreecommitdiff
path: root/src/cleaners
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-08 10:03:43 -0500
committermat <github@matdoes.dev>2022-05-08 10:03:43 -0500
commitb1c6c3aa3ae1b8e66122f8d7eeea1c52c131a339 (patch)
tree3df2b41a8392033da0e579bb487e7b5b7fb332a0 /src/cleaners
parent15dbc7c3a1f76693cd83198861e94f211dbb1cb1 (diff)
downloadskyblock-api-b1c6c3aa3ae1b8e66122f8d7eeea1c52c131a339.tar.gz
skyblock-api-b1c6c3aa3ae1b8e66122f8d7eeea1c52c131a339.tar.bz2
skyblock-api-b1c6c3aa3ae1b8e66122f8d7eeea1c52c131a339.zip
fix people joining coops before they were invited
time travelers probably
Diffstat (limited to 'src/cleaners')
-rw-r--r--src/cleaners/skyblock/coopInvitation.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/cleaners/skyblock/coopInvitation.ts b/src/cleaners/skyblock/coopInvitation.ts
index 0188772..031135b 100644
--- a/src/cleaners/skyblock/coopInvitation.ts
+++ b/src/cleaners/skyblock/coopInvitation.ts
@@ -14,10 +14,20 @@ export async function cleanCoopInvitation(data: typedHypixelApi.SkyBlockProfileM
if (!data.coop_invitation)
return null
+ let invitedTimestamp = data.coop_invitation.timestamp
+ let acceptedTimestamp = data.coop_invitation.confirmed_timestamp ?? null
+
+ // the accepted timestamp should always be greater, otherwise swap
+ if (acceptedTimestamp !== null && invitedTimestamp > acceptedTimestamp) {
+ let temp = invitedTimestamp
+ invitedTimestamp = acceptedTimestamp
+ acceptedTimestamp = temp
+ }
+
return {
- invitedTimestamp: data.coop_invitation.timestamp,
+ invitedTimestamp,
invitedBy: await cached.fetchBasicPlayer(data.coop_invitation.invited_by, false),
accepted: data.coop_invitation.confirmed,
- acceptedTimestamp: data.coop_invitation.confirmed_timestamp ?? null
+ acceptedTimestamp
}
} \ No newline at end of file