diff options
author | mat <github@matdoes.dev> | 2022-04-09 13:19:20 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-04-09 13:19:20 -0500 |
commit | 3d4d9e51880aa665541e335bcd5dfa8c9bce2299 (patch) | |
tree | 97670a92bf1e41160c53458621bc65454bcbd0a8 /src/cleaners/skyblock | |
parent | aca2096adb2568c4c19fff96c293aa9a625002be (diff) | |
download | skyblock-api-3d4d9e51880aa665541e335bcd5dfa8c9bce2299.tar.gz skyblock-api-3d4d9e51880aa665541e335bcd5dfa8c9bce2299.tar.bz2 skyblock-api-3d4d9e51880aa665541e335bcd5dfa8c9bce2299.zip |
return whole player in coopInvitation
Diffstat (limited to 'src/cleaners/skyblock')
-rw-r--r-- | src/cleaners/skyblock/coopInvitation.ts | 9 | ||||
-rw-r--r-- | src/cleaners/skyblock/member.ts | 22 |
2 files changed, 21 insertions, 10 deletions
diff --git a/src/cleaners/skyblock/coopInvitation.ts b/src/cleaners/skyblock/coopInvitation.ts index 80c92bb..6aa8803 100644 --- a/src/cleaners/skyblock/coopInvitation.ts +++ b/src/cleaners/skyblock/coopInvitation.ts @@ -1,18 +1,21 @@ import typedHypixelApi from 'typed-hypixel-api' +import { CleanPlayer } from '../player' +import * as cached from '../../hypixelCached.js' + export interface CoopInvitation { invitedTimestamp: number - invitedByUuid: string + invitedBy: CleanPlayer | null accepted: boolean acceptedTimestamp: number | null } -export function cleanCoopInvitation(data: typedHypixelApi.SkyBlockProfileMember): null | CoopInvitation { +export async function cleanCoopInvitation(data: typedHypixelApi.SkyBlockProfileMember): Promise<CoopInvitation | null> { if (!data.coop_invitation) return null return { invitedTimestamp: data.coop_invitation.timestamp, - invitedByUuid: data.coop_invitation.invited_by, + invitedBy: await cached.fetchBasicPlayer(data.coop_invitation.invited_by, false), accepted: data.coop_invitation.confirmed, acceptedTimestamp: data.coop_invitation.confirmed_timestamp ?? null } diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts index 9306c59..9231456 100644 --- a/src/cleaners/skyblock/member.ts +++ b/src/cleaners/skyblock/member.ts @@ -72,6 +72,14 @@ export async function cleanSkyBlockProfileMemberResponse(member: typedHypixelApi if (fairySouls.total > (maxFairySouls ?? 0)) await constants.setConstantValues({ max_fairy_souls: fairySouls.total }) + const coopInvitationPromise = cleanCoopInvitation(member) + const minionsPromise = cleanMinions(member) + const skillsPromise = cleanSkills(member) + const zonesPromise = cleanVisitedZones(member) + const petsPromise = cleanPets(member) + const harpPromise = cleanHarp(member) + const inventoriesPromise = inventoriesIncluded ? cleanInventories(member) : Promise.resolve(undefined) + return { uuid: member.uuid, username: player.username, @@ -87,17 +95,17 @@ export async function cleanSkyBlockProfileMemberResponse(member: typedHypixelApi // this is used for leaderboards rawHypixelStats: member.stats ?? {}, - minions: await cleanMinions(member), + minions: await minionsPromise, fairySouls: fairySouls, - inventories: inventoriesIncluded ? await cleanInventories(member) : undefined, + inventories: inventoriesPromise ? await inventoriesPromise : undefined, objectives: cleanObjectives(member), - skills: await cleanSkills(member), - zones: await cleanVisitedZones(member), + skills: await skillsPromise, + zones: await zonesPromise, collections: cleanCollections(member), slayers: cleanSlayers(member), - pets: await cleanPets(member), - harp: await cleanHarp(member), - coopInvitation: cleanCoopInvitation(member), + pets: await petsPromise, + harp: await harpPromise, + coopInvitation: await coopInvitationPromise, farmingContests: cleanFarmingContests(member), left: (player.profiles?.find(profile => profile.uuid === profileId) === undefined) ?? false |