diff options
author | mat <github@matdoes.dev> | 2021-06-30 01:15:19 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-06-30 01:15:19 -0500 |
commit | 03991ab4890202dcfd5415da66773638245dccf1 (patch) | |
tree | 663e8fe2e9f3e4fbf3298970565261baebbe02d6 /src/cleaners/skyblock | |
parent | 568c74568c1397ea0db329b205e6ff6fd80eabd4 (diff) | |
download | skyblock-api-03991ab4890202dcfd5415da66773638245dccf1.tar.gz skyblock-api-03991ab4890202dcfd5415da66773638245dccf1.tar.bz2 skyblock-api-03991ab4890202dcfd5415da66773638245dccf1.zip |
fix error that happens sometimes for nonexistent players
Diffstat (limited to 'src/cleaners/skyblock')
-rw-r--r-- | src/cleaners/skyblock/profile.ts | 4 | ||||
-rw-r--r-- | src/cleaners/skyblock/profiles.ts | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/cleaners/skyblock/profile.ts b/src/cleaners/skyblock/profile.ts index 5bcea4b..e4d2a94 100644 --- a/src/cleaners/skyblock/profile.ts +++ b/src/cleaners/skyblock/profile.ts @@ -46,10 +46,10 @@ export async function cleanSkyblockProfileResponseLighter(data): Promise<CleanPr /** * This function is somewhat costly and shouldn't be called often. Use cleanSkyblockProfileResponseLighter if you don't need all the data */ -export async function cleanSkyblockProfileResponse(data: any, options?: ApiOptions): Promise<CleanFullProfile|CleanProfile> { +export async function cleanSkyblockProfileResponse(data: any, options?: ApiOptions): Promise<CleanFullProfile | CleanProfile | null> { // We use Promise.all so it can fetch all the users at once instead of waiting for the previous promise to complete const promises: Promise<CleanMember | null>[] = [] - + if (!data) return null for (const memberUUID in data.members) { const memberRaw = data.members[memberUUID] memberRaw.uuid = memberUUID diff --git a/src/cleaners/skyblock/profiles.ts b/src/cleaners/skyblock/profiles.ts index a44fe48..a068dae 100644 --- a/src/cleaners/skyblock/profiles.ts +++ b/src/cleaners/skyblock/profiles.ts @@ -19,11 +19,11 @@ export function cleanPlayerSkyblockProfiles(rawProfiles: HypixelPlayerStatsSkyBl /** Convert an array of raw profiles into clean profiles */ export async function cleanSkyblockProfilesResponse(data: any[]): Promise<CleanProfile[]> { - const promises: Promise<CleanProfile | CleanFullProfile>[] = [] + const promises: Promise<CleanProfile | CleanFullProfile | null>[] = [] for (const profile of data ?? []) { // let cleanedProfile = await cleanSkyblockProfileResponseLighter(profile) promises.push(cleanSkyblockProfileResponse(profile)) } - const cleanedProfiles: CleanProfile[] = await Promise.all(promises) + const cleanedProfiles: CleanProfile[] = (await Promise.all(promises)).filter(p => p) as CleanProfile[] return cleanedProfiles } |