From 03537cf0cce0a19740c069c700374cafe176b3b5 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 26 Mar 2022 13:17:48 -0500 Subject: Change a lot of things to use typed-hypixel-api --- src/hypixel.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/hypixel.ts') 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

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

(path: P, data: typedHypixelApi.Requests[P]['response'], options: ApiOptions): Promise>> { +async function cleanResponse

( + path: P, + data: typedHypixelApi.Requests[P]['response'], + options: ApiOptions +): Promise>> { // 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> } -- cgit