diff options
Diffstat (limited to 'src/cleaners/skyblock/profile.ts')
-rw-r--r-- | src/cleaners/skyblock/profile.ts | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/cleaners/skyblock/profile.ts b/src/cleaners/skyblock/profile.ts index 2b092a1..6e98f8f 100644 --- a/src/cleaners/skyblock/profile.ts +++ b/src/cleaners/skyblock/profile.ts @@ -8,7 +8,14 @@ export interface CleanProfile extends CleanBasicProfile { } export interface CleanFullProfile extends CleanProfile { - members: (CleanMember|CleanBasicMember)[] + members: CleanMember[] + bank: Bank + minions: CleanMinion[] + minion_count: number +} + +export interface CleanFullProfileBasicMembers extends CleanProfile { + members: CleanBasicMember[] bank: Bank minions: CleanMinion[] minion_count: number @@ -38,19 +45,21 @@ 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, { mainMemberUuid }: ApiOptions): Promise<CleanFullProfile> { - const cleanedMembers: CleanMember[] = [] - +export async function cleanSkyblockProfileResponse(data: any, options?: ApiOptions): Promise<CleanFullProfile> { + // 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>[] = [] + for (const memberUUID in data.members) { const memberRaw = data.members[memberUUID] memberRaw.uuid = memberUUID - const member: CleanMember = await cleanSkyBlockProfileMemberResponse( + promises.push(cleanSkyBlockProfileMemberResponse( memberRaw, - ['stats', mainMemberUuid === memberUUID ? 'inventories' : undefined] - ) - cleanedMembers.push(member) + ['stats', options?.mainMemberUuid === memberUUID ? 'inventories' : undefined] + )) } + const cleanedMembers: CleanMember[] = await Promise.all(promises) + const memberMinions: CleanMinion[][] = [] for (const member of cleanedMembers) { |