From ee0ce21292dc53d11b5d6613465c502b0bb7a34a Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Tue, 2 Mar 2021 10:27:47 -0600 Subject: fix some errors with invalid players --- src/hypixelCached.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/hypixelCached.ts') diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts index 483b3fa..0d5e0e3 100644 --- a/src/hypixelCached.ts +++ b/src/hypixelCached.ts @@ -78,6 +78,10 @@ export async function uuidFromUser(user: string): Promise { if (usernameCache.has(undashUuid(user))) { // check if the uuid is a key const username: any = usernameCache.get(undashUuid(user)) + + // sometimes the username will be null, return that + if (username === null) return username + // if it has .then, then that means its a waitForCacheSet promise. This is done to prevent requests made while it is already requesting if (username.then) { const { key: uuid, value: _username } = await username @@ -209,6 +213,9 @@ export async function fetchSkyblockProfiles(playerUuid: string): Promise { const playerUuid = await uuidFromUser(user) + + if (!playerUuid) return // invalid player, just return + if (basicProfilesCache.has(playerUuid)) { if (debug) console.log('Cache hit! fetchBasicProfiles', playerUuid) return basicProfilesCache.get(playerUuid) @@ -242,6 +249,7 @@ export async function fetchProfileUuid(user: string, profile: string) { if (debug) console.log('Cache miss: fetchProfileUuid', user) const profiles = await fetchBasicProfiles(user) + if (!profiles) return // user probably doesnt exist const profileUuid = undashUuid(profile) -- cgit