diff options
author | mat <github@matdoes.dev> | 2022-03-26 13:17:48 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-03-26 13:17:48 -0500 |
commit | 03537cf0cce0a19740c069c700374cafe176b3b5 (patch) | |
tree | 9ce3bd8911c04f8670b6baf504304763cd91325b /src/hypixel.ts | |
parent | 6b94d0110a52a355758432ff6cd14c80553471ea (diff) | |
download | skyblock-api-03537cf0cce0a19740c069c700374cafe176b3b5.tar.gz skyblock-api-03537cf0cce0a19740c069c700374cafe176b3b5.tar.bz2 skyblock-api-03537cf0cce0a19740c069c700374cafe176b3b5.zip |
Change a lot of things to use typed-hypixel-api
Diffstat (limited to 'src/hypixel.ts')
-rw-r--r-- | src/hypixel.ts | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/hypixel.ts b/src/hypixel.ts index 4ae299a..eede92b 100644 --- a/src/hypixel.ts +++ b/src/hypixel.ts @@ -54,16 +54,21 @@ export async function sendCleanApiRequest<P extends keyof typeof cleanResponseFu const cleanResponseFunctions = { 'player': (data, options) => cleanPlayerResponse(data.player), - 'skyblock/profile': (data, options) => cleanSkyblockProfileResponse(data.profile, options), + 'skyblock/profile': (data: typedHypixelApi.SkyBlockProfileResponse, options) => cleanSkyblockProfileResponse(data.profile, options), 'skyblock/profiles': (data, options) => cleanSkyblockProfilesResponse(data.profiles), 'resources/skyblock/election': (data, options) => cleanElectionResponse(data) } as const -async function cleanResponse<P extends keyof typeof cleanResponseFunctions>(path: P, data: typedHypixelApi.Requests[P]['response'], options: ApiOptions): Promise<Awaited<ReturnType<typeof cleanResponseFunctions[P]>>> { +async function cleanResponse<P extends keyof typeof cleanResponseFunctions>( + path: P, + data: typedHypixelApi.Requests[P]['response'], + options: ApiOptions +): Promise<Awaited<ReturnType<typeof cleanResponseFunctions[P]>>> { // Cleans up an api response const cleaningFunction: typeof cleanResponseFunctions[P] = cleanResponseFunctions[path] - const cleanedData = await cleaningFunction(data, options) + // we do `as any` because typescript unfortunately doesn't know which path it is + const cleanedData = await cleaningFunction(data as any, options) return cleanedData as Awaited<ReturnType<typeof cleanResponseFunctions[P]>> } |