diff options
author | mat <github@matdoes.dev> | 2022-03-27 12:17:27 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-03-27 12:17:27 -0500 |
commit | b48e0ba124ce70ff18948c4998efa20fa6c3731e (patch) | |
tree | 74efcf7f751590c110394e23581fcadfd7129a2b /src | |
parent | 03537cf0cce0a19740c069c700374cafe176b3b5 (diff) | |
download | skyblock-api-b48e0ba124ce70ff18948c4998efa20fa6c3731e.tar.gz skyblock-api-b48e0ba124ce70ff18948c4998efa20fa6c3731e.tar.bz2 skyblock-api-b48e0ba124ce70ff18948c4998efa20fa6c3731e.zip |
fix and bump typed-hypixel-api version
Diffstat (limited to 'src')
-rw-r--r-- | src/cleaners/skyblock/member.ts | 11 | ||||
-rw-r--r-- | src/hypixel.ts | 2 | ||||
-rw-r--r-- | src/hypixelApi.ts | 4 |
3 files changed, 9 insertions, 8 deletions
diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts index aa102e1..c8f5b79 100644 --- a/src/cleaners/skyblock/member.ts +++ b/src/cleaners/skyblock/member.ts @@ -47,8 +47,8 @@ export async function cleanSkyBlockProfileMemberResponseBasic(member: typedHypix return { uuid: member.uuid, username: player.username, - lastSave: member.last_save, - firstJoin: member.first_join, + lastSave: member.last_save ?? 0, + firstJoin: member.first_join ?? 0, rank: player.rank } } @@ -68,11 +68,12 @@ export async function cleanSkyBlockProfileMemberResponse(member: typedHypixelApi return { uuid: member.uuid, username: player.username, - lastSave: member.last_save, - firstJoin: member.first_join, + // members that haven't joined the profile have no last save or first join + lastSave: member.last_save ?? 0, + firstJoin: member.first_join ?? 0, rank: player.rank, - purse: member.coin_purse, + purse: member.coin_purse ?? 0, stats: cleanProfileStats(member), diff --git a/src/hypixel.ts b/src/hypixel.ts index eede92b..4afac53 100644 --- a/src/hypixel.ts +++ b/src/hypixel.ts @@ -68,7 +68,7 @@ async function cleanResponse<P extends keyof typeof cleanResponseFunctions>( // Cleans up an api response const cleaningFunction: typeof cleanResponseFunctions[P] = cleanResponseFunctions[path] // we do `as any` because typescript unfortunately doesn't know which path it is - const cleanedData = await cleaningFunction(data as any, options) + const cleanedData = await cleaningFunction(data.data as any, options) return cleanedData as Awaited<ReturnType<typeof cleanResponseFunctions[P]>> } diff --git a/src/hypixelApi.ts b/src/hypixelApi.ts index 186cec6..3a9cf95 100644 --- a/src/hypixelApi.ts +++ b/src/hypixelApi.ts @@ -1,7 +1,7 @@ /** * Fetch the raw Hypixel API */ -import { shuffle, sleep } from './util.js' +import { shuffle, sleep } from './util.js' import typedHypixelApi from 'typed-hypixel-api' import { Agent } from 'https' @@ -107,7 +107,7 @@ export let sendApiRequest = async<P extends keyof typedHypixelApi.Requests>(path path, options ) - } catch { + } catch (e) { await sleep(1000) return await sendApiRequest(path, options) } |