aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-03-27 13:27:45 -0500
committermat <github@matdoes.dev>2022-03-27 13:27:45 -0500
commit3531a091e052c1c8554fa974ad825dc0f4d6bf09 (patch)
tree782e6195b32e8beeaeda58906fae5603374c0a92 /src
parenta02f03a0625885cbc41e95c09ecd9178b27adda2 (diff)
downloadskyblock-api-3531a091e052c1c8554fa974ad825dc0f4d6bf09.tar.gz
skyblock-api-3531a091e052c1c8554fa974ad825dc0f4d6bf09.tar.bz2
skyblock-api-3531a091e052c1c8554fa974ad825dc0f4d6bf09.zip
Claimed items (scorpius bribes, potato talisman, etc)
Diffstat (limited to 'src')
-rw-r--r--src/cleaners/player.ts12
-rw-r--r--src/cleaners/skyblock/claimed.ts44
-rw-r--r--src/cleaners/skyblock/member.ts1
3 files changed, 54 insertions, 3 deletions
diff --git a/src/cleaners/player.ts b/src/cleaners/player.ts
index 9392826..3981609 100644
--- a/src/cleaners/player.ts
+++ b/src/cleaners/player.ts
@@ -1,5 +1,6 @@
-import { cleanPlayerSkyblockProfiles } from './skyblock/profiles.js'
import { cleanSocialMedia, CleanSocialMedia } from './socialmedia.js'
+import { cleanPlayerSkyblockProfiles } from './skyblock/profiles.js'
+import { cleanPlayerSkyblockClaimed } from './skyblock/claimed.js'
import { CleanBasicProfile } from './skyblock/profile.js'
import { cleanRank, CleanRank } from './rank.js'
import typedHypixelApi from 'typed-hypixel-api'
@@ -10,10 +11,16 @@ export interface CleanBasicPlayer {
username: string
}
+export interface ClaimedSkyBlockItem {
+ name: string
+ timestamp: number
+}
+
export interface CleanPlayer extends CleanBasicPlayer {
rank: CleanRank
socials: CleanSocialMedia
profiles?: CleanBasicProfile[]
+ skyblockClaimed?: ClaimedSkyBlockItem[]
}
export async function cleanPlayerResponse(data: typedHypixelApi.PlayerDataResponse['player']): Promise<CleanPlayer | null> {
@@ -25,6 +32,7 @@ export async function cleanPlayerResponse(data: typedHypixelApi.PlayerDataRespon
username: data.displayname,
rank: cleanRank(data),
socials: cleanSocialMedia(data),
- profiles: cleanPlayerSkyblockProfiles(data.stats?.SkyBlock?.profiles)
+ profiles: cleanPlayerSkyblockProfiles(data.stats?.SkyBlock?.profiles),
+ skyblockClaimed: cleanPlayerSkyblockClaimed(data)
}
}
diff --git a/src/cleaners/skyblock/claimed.ts b/src/cleaners/skyblock/claimed.ts
new file mode 100644
index 0000000..3a4631e
--- /dev/null
+++ b/src/cleaners/skyblock/claimed.ts
@@ -0,0 +1,44 @@
+import { HypixelPlayerStatsSkyBlockProfiles } from '../../hypixelApi.js'
+import {
+ CleanBasicProfile,
+ CleanFullProfile,
+ cleanSkyblockProfileResponse
+} from './profile.js'
+import typedHypixelApi from 'typed-hypixel-api'
+import { ClaimedSkyBlockItem } from '../player.js'
+
+export function cleanPlayerSkyblockClaimed(data: typedHypixelApi.PlayerDataResponse['player']): ClaimedSkyBlockItem[] {
+ const claimedItems: ClaimedSkyBlockItem[] = []
+
+ if (data.claimed_potato_talisman)
+ claimedItems.push({
+ name: 'potato_talisman',
+ timestamp: data.claimed_potato_talisman
+ })
+ if (data.claimed_century_cake)
+ claimedItems.push({
+ name: 'century_cake',
+ timestamp: data.claimed_century_cake
+ })
+ if (data.claimed_year143_cake)
+ claimedItems.push({
+ name: 'year_143_cake',
+ timestamp: data.claimed_year143_cake
+ })
+ if (data.skyblock_free_cookie)
+ claimedItems.push({
+ name: 'free_booster_cookie',
+ timestamp: data.skyblock_free_cookie
+ })
+
+ const scorpiusBribes = Object.keys(data).filter((key) => key.startsWith('scorpius_bribe_'))
+ for (const bribe of scorpiusBribes) {
+ const bribeYear = bribe.slice('scorpius_bribe_'.length)
+ claimedItems.push({
+ name: `year_${bribeYear}_scorpius_bribe`,
+ timestamp: data[bribe]
+ })
+ }
+
+ return claimedItems
+}
diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts
index c8f5b79..364e8b3 100644
--- a/src/cleaners/skyblock/member.ts
+++ b/src/cleaners/skyblock/member.ts
@@ -55,7 +55,6 @@ export async function cleanSkyBlockProfileMemberResponseBasic(member: typedHypix
/** Cleans up a member (from skyblock/profile) */
export async function cleanSkyBlockProfileMemberResponse(member: typedHypixelApi.SkyBlockProfileMember & { uuid: string }, profileId?: string, included: Included[] | undefined = undefined): Promise<CleanMember | null> {
- // profiles.members[]
const inventoriesIncluded = included === undefined || included.includes('inventories')
const player = await cached.fetchPlayer(member.uuid)
if (!player) return null