diff options
-rw-r--r-- | package-lock.json | 18 | ||||
-rw-r--r-- | package.json | 4 | ||||
-rw-r--r-- | src/cleaners/skyblock/member.ts | 11 | ||||
-rw-r--r-- | src/hypixel.ts | 2 | ||||
-rw-r--r-- | src/hypixelApi.ts | 4 |
5 files changed, 20 insertions, 19 deletions
diff --git a/package-lock.json b/package-lock.json index 02de409..c672ac4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "prismarine-nbt": "github:PrismarineJS/prismarine-nbt", "prom-client": "^14.0.1", "queue-promise": "^2.2.1", - "typed-hypixel-api": "^0.2.1", + "typed-hypixel-api": "^0.3.2", "uuid": "^8.3.2" }, "devDependencies": { @@ -1936,11 +1936,11 @@ } }, "node_modules/typed-hypixel-api": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-0.2.1.tgz", - "integrity": "sha512-7tjImNlekq/GBR19t5wowxYd5bblkrNdRCS1U63yli41YTBxiHm7Ws6FGN1pY7/Oospdr0jhQyT8/csCLWldGw==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-0.3.2.tgz", + "integrity": "sha512-x1aHU7MOJxmnZSuivAipwutjWwUL8ncu3HS8qwTnlflFr2EkzYnppKWdHXZndTC219fVQDVz9eplKWPYvHCfFg==", "dependencies": { - "typescript": "^4.6.2", + "typescript": "^4.6.3", "undici": "^4.16.0" } }, @@ -3623,11 +3623,11 @@ } }, "typed-hypixel-api": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-0.2.1.tgz", - "integrity": "sha512-7tjImNlekq/GBR19t5wowxYd5bblkrNdRCS1U63yli41YTBxiHm7Ws6FGN1pY7/Oospdr0jhQyT8/csCLWldGw==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-0.3.2.tgz", + "integrity": "sha512-x1aHU7MOJxmnZSuivAipwutjWwUL8ncu3HS8qwTnlflFr2EkzYnppKWdHXZndTC219fVQDVz9eplKWPYvHCfFg==", "requires": { - "typescript": "^4.6.2", + "typescript": "^4.6.3", "undici": "^4.16.0" } }, diff --git a/package.json b/package.json index 8e16b28..6d6690d 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "prismarine-nbt": "github:PrismarineJS/prismarine-nbt", "prom-client": "^14.0.1", "queue-promise": "^2.2.1", - "typed-hypixel-api": "^0.2.1", + "typed-hypixel-api": "^0.3.2", "uuid": "^8.3.2" }, "devDependencies": { @@ -52,4 +52,4 @@ "typescript": "^4.6.3" }, "type": "module" -}
\ No newline at end of file +} 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) } |