aboutsummaryrefslogtreecommitdiff
path: root/src/cleaners
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-02-13 16:28:26 -0600
committermat <27899617+mat-1@users.noreply.github.com>2021-02-13 16:28:26 -0600
commit5c9ef89af1ee9af380ea82072a3a48d5db0f2c7a (patch)
tree8d3f2fc286a7f18931b1d561cf376b897e8f6d18 /src/cleaners
parentdd513537e240bbaf12c4f204d49db88111633d98 (diff)
downloadskyblock-api-5c9ef89af1ee9af380ea82072a3a48d5db0f2c7a.tar.gz
skyblock-api-5c9ef89af1ee9af380ea82072a3a48d5db0f2c7a.tar.bz2
skyblock-api-5c9ef89af1ee9af380ea82072a3a48d5db0f2c7a.zip
move some code to make more sense
Diffstat (limited to 'src/cleaners')
-rw-r--r--src/cleaners/skyblock/profile.ts40
1 files changed, 4 insertions, 36 deletions
diff --git a/src/cleaners/skyblock/profile.ts b/src/cleaners/skyblock/profile.ts
index 8389a0d..742c9ed 100644
--- a/src/cleaners/skyblock/profile.ts
+++ b/src/cleaners/skyblock/profile.ts
@@ -10,8 +10,9 @@ export interface CleanProfile extends CleanBasicProfile {
export interface CleanFullProfile extends CleanProfile {
members: CleanMember[]
- bank?: Bank
+ bank: Bank
minions: CleanMinion[]
+ minion_count: number
}
/** Return a `CleanProfile` instead of a `CleanFullProfile`, useful when we need to get members but don't want to waste much ram */
@@ -59,7 +60,8 @@ export async function cleanSkyblockProfileResponse(data: any): Promise<CleanFull
name: data.cute_name,
members: cleanedMembers,
bank: cleanBank(data),
- minions
+ minions: minions,
+ minion_count: countUniqueMinions(minions)
}
}
@@ -71,37 +73,3 @@ export interface CleanBasicProfile {
name?: string
}
-// TODO: this should be moved and split up
-/**
- * Fetch a CleanMemberProfile from a user and string
- * This is safe to use many times as the results are cached!
- * @param user A username or uuid
- * @param profile A profile name or profile uuid
- */
-export async function fetchMemberProfile(user: string, profile: string): Promise<CleanMemberProfile> {
- const playerUuid = await cached.uuidFromUser(user)
- const profileUuid = await cached.fetchProfileUuid(user, profile)
-
- const player = await cached.fetchPlayer(playerUuid)
-
- const cleanProfile = await cached.fetchProfile(playerUuid, profileUuid)
-
- const member = cleanProfile.members.find(m => m.uuid === playerUuid)
-
- return {
- member: {
- // the profile name is in member rather than profile since they sometimes differ for each member
- profileName: cleanProfile.name,
- // add all the member data
- ...member,
- // add all other data relating to the hypixel player, such as username, rank, etc
- ...player
- },
- profile: {
- uuid: cleanProfile.uuid,
- bank: cleanProfile.bank,
- minions: cleanProfile.minions,
- minion_count: countUniqueMinions(cleanProfile.minions)
- }
- }
-}