aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cleaners/skyblock/profile.ts40
-rw-r--r--src/hypixel.ts28
-rw-r--r--src/index.ts3
3 files changed, 33 insertions, 38 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)
- }
- }
-}
diff --git a/src/hypixel.ts b/src/hypixel.ts
index 5a13845..bbfc7d2 100644
--- a/src/hypixel.ts
+++ b/src/hypixel.ts
@@ -116,3 +116,31 @@ export async function fetchUser({ user, uuid, username }: UserAny, included: Inc
}
}
+/**
+ * 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: cleanProfile
+ }
+}
diff --git a/src/index.ts b/src/index.ts
index 6b55923..c0047ad 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,5 +1,4 @@
-import { fetchMemberProfile } from './cleaners/skyblock/profile'
-import { fetchUser } from './hypixel'
+import { fetchMemberProfile, fetchUser } from './hypixel'
import express from 'express'
const app = express()