From 6b94d0110a52a355758432ff6cd14c80553471ea Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 25 Mar 2022 21:13:13 -0500 Subject: Add typed-hypixel-api as a dep and change some code --- src/hypixelCached.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/hypixelCached.ts') diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts index bc34ef0..5a17c3c 100644 --- a/src/hypixelCached.ts +++ b/src/hypixelCached.ts @@ -174,10 +174,9 @@ export async function fetchPlayer(user: string): Promise { fetchingPlayers.add(playerUuid) - const cleanPlayer: CleanPlayer = await hypixel.sendCleanApiRequest({ - path: 'player', - args: { uuid: playerUuid } - }) + const cleanPlayer = await hypixel.sendCleanApiRequest('player', + { uuid: playerUuid } + ) fetchingPlayers.delete(playerUuid) @@ -185,7 +184,7 @@ export async function fetchPlayer(user: string): Promise { playerCache.set(playerUuid, cleanPlayer) usernameCache.set(playerUuid, cleanPlayer.username) - + // clone in case it gets modified somehow later const cleanBasicPlayer = Object.assign({}, cleanPlayer) if (cleanBasicPlayer.profiles) { @@ -335,7 +334,8 @@ export async function fetchProfile(user: string, profile: string): Promise { +export async function fetchBasicProfileFromUuid(profileUuid: string): Promise { if (profileCache.has(profileUuid)) { // we have the profile cached, return it :) if (debug) console.debug('Cache hit! fetchBasicProfileFromUuid', profileUuid) const profile: CleanFullProfile | undefined = profileCache.get(profileUuid) - if (!profile) return undefined + if (!profile) return null return { uuid: profile.uuid, members: profile.members.map(m => ({ -- cgit