aboutsummaryrefslogtreecommitdiff
path: root/src/hypixel.ts
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-19 18:55:26 +0000
committermat <github@matdoes.dev>2022-05-19 18:55:35 +0000
commit6cb86433e0190cdead1e213fa3d11391ba9c56e4 (patch)
tree062340dcd41dd9ebd79928e879665f77986d3139 /src/hypixel.ts
parent11e18feb755488cfb8f65fcf7db0204b997e41c9 (diff)
downloadskyblock-api-6cb86433e0190cdead1e213fa3d11391ba9c56e4.tar.gz
skyblock-api-6cb86433e0190cdead1e213fa3d11391ba9c56e4.tar.bz2
skyblock-api-6cb86433e0190cdead1e213fa3d11391ba9c56e4.zip
better achievements
Diffstat (limited to 'src/hypixel.ts')
-rw-r--r--src/hypixel.ts11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/hypixel.ts b/src/hypixel.ts
index e0575dd..ba0b83c 100644
--- a/src/hypixel.ts
+++ b/src/hypixel.ts
@@ -53,13 +53,18 @@ export interface ApiOptions {
basic?: boolean
}
-/** Sends an API request to Hypixel and cleans it up. */
-export async function sendCleanApiRequest<P extends keyof typeof cleanResponseFunctions>(path: P, args: Omit<typedHypixelApi.Requests[P]['options'], 'key'>, options?: ApiOptions): Promise<Awaited<ReturnType<typeof cleanResponseFunctions[P]>>> {
+/** Sends an API request to Hypixel and returns the response. */
+export async function sendUncleanApiRequest<P extends keyof typedHypixelApi.Requests>(path: P, args: Omit<typedHypixelApi.Requests[P]['options'], 'key'>): Promise<typedHypixelApi.Requests[P]['response']['data']> {
const key = await chooseApiKey()
const data = await sendApiRequest(path, { key, ...args })
if (!data)
throw new Error(`No data returned from ${path}`)
- // clean the response
+ return data
+}
+
+/** Sends an API request to Hypixel and cleans it up. */
+export async function sendCleanApiRequest<P extends keyof typeof cleanResponseFunctions>(path: P, args: Omit<typedHypixelApi.Requests[P]['options'], 'key'>, options?: ApiOptions): Promise<Awaited<ReturnType<typeof cleanResponseFunctions[P]>>> {
+ const data = await sendUncleanApiRequest(path, args)
return await cleanResponse(path, data, options ?? {})
}