From 4b2e9e4435cf3a37cd791bee0dc942e0459538e8 Mon Sep 17 00:00:00 2001 From: Jacob Date: Thu, 15 Aug 2024 09:17:03 +0800 Subject: [PATCH] Remove Dead uuidCache code --- src/API/getPlayer.ts | 2 ++ src/API/getSkyblockMember.ts | 4 ++++ src/Private/uuidCache.ts | 32 -------------------------------- src/index.ts | 1 - 4 files changed, 6 insertions(+), 33 deletions(-) delete mode 100644 src/Private/uuidCache.ts diff --git a/src/API/getPlayer.ts b/src/API/getPlayer.ts index ac2fd616..9155886d 100644 --- a/src/API/getPlayer.ts +++ b/src/API/getPlayer.ts @@ -16,6 +16,8 @@ export default class getPlayer extends Endpoint { const res = await this.client.requests.request(`/player?uuid=${query}`, options); if (res.raw) return res; if (query && !res.player) throw new Error(this.client.errors.PLAYER_HAS_NEVER_LOGGED); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error return new Player(res.player, options?.getGuild ? await this.client.getGuild('player', query) : undefined); } } diff --git a/src/API/getSkyblockMember.ts b/src/API/getSkyblockMember.ts index cef352a5..22bb687d 100644 --- a/src/API/getSkyblockMember.ts +++ b/src/API/getSkyblockMember.ts @@ -23,7 +23,11 @@ export default class getSkyblockMember extends Endpoint { new SkyblockMember({ uuid: query, profileId: profile.profile_id, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error garden: options?.garden ? await this.client.getSkyblockGarden(profile.profile_id) : null, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error museum: options?.garden ? await this.client.getSkyblockMuseum(query, profile.profile_id) : null, profileName: profile.cute_name, gameMode: profile.game_mode || null, diff --git a/src/Private/uuidCache.ts b/src/Private/uuidCache.ts deleted file mode 100644 index 40222e90..00000000 --- a/src/Private/uuidCache.ts +++ /dev/null @@ -1,32 +0,0 @@ -import NodeCache from 'node-cache'; -const cache = new NodeCache(); -import axios from 'axios'; - -export interface CacheData { - status: number; - id: string | null; - name: string | null; -} - -export default async function (url: string, query: string, cacheTime: number): Promise { - if (cache.has(query.toLowerCase())) return cache.get(query.toLowerCase()) as CacheData; - const res = await axios.get(url); - const data = await res.data; - // Don't cache 4xx - if (400 <= res.status) { - return { - status: res.status, - id: null, - name: null - }; - } - - cache.set(query.toLowerCase(), { status: res.status, id: data.id, name: data.name }, cacheTime); - cache.set(data.id.toLowerCase(), { status: res.status, id: data.id, name: data.name }, cacheTime); - - return { - status: res.status, - id: data.id, - name: data.name - }; -} diff --git a/src/index.ts b/src/index.ts index d6e3da9d..cbb50d73 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,6 @@ export * from './Private/CacheHandler'; export * from './Private/Updater'; export * from './Private/Endpoint'; export * from './Private/Requests'; -export * from './Private/uuidCache'; export * from './API/getAchievements'; export * from './API/getActiveHouses';