diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cleaners/player.ts | 4 | ||||
-rw-r--r-- | src/cleaners/rank.ts | 4 | ||||
-rw-r--r-- | src/cleaners/skyblock/bank.ts | 5 | ||||
-rw-r--r-- | src/cleaners/skyblock/collections.ts | 11 | ||||
-rw-r--r-- | src/cleaners/skyblock/election.ts | 10 | ||||
-rw-r--r-- | src/cleaners/skyblock/fairysouls.ts | 3 | ||||
-rw-r--r-- | src/cleaners/skyblock/inventory.ts | 9 | ||||
-rw-r--r-- | src/cleaners/skyblock/member.ts | 6 | ||||
-rw-r--r-- | src/cleaners/skyblock/minions.ts | 5 | ||||
-rw-r--r-- | src/cleaners/skyblock/objectives.ts | 5 | ||||
-rw-r--r-- | src/cleaners/skyblock/profile.ts | 21 | ||||
-rw-r--r-- | src/cleaners/skyblock/profiles.ts | 5 | ||||
-rw-r--r-- | src/cleaners/skyblock/skills.ts | 14 | ||||
-rw-r--r-- | src/cleaners/skyblock/slayers.ts | 4 | ||||
-rw-r--r-- | src/cleaners/skyblock/stats.ts | 9 | ||||
-rw-r--r-- | src/cleaners/skyblock/zones.ts | 5 | ||||
-rw-r--r-- | src/hypixel.ts | 11 |
17 files changed, 80 insertions, 51 deletions
diff --git a/src/cleaners/player.ts b/src/cleaners/player.ts index 6467e59..9392826 100644 --- a/src/cleaners/player.ts +++ b/src/cleaners/player.ts @@ -1,8 +1,8 @@ -import { PlayerDataResponse as HypixelApiPlayerDataResponse } from 'typed-hypixel-api/build/responses/player' import { cleanPlayerSkyblockProfiles } from './skyblock/profiles.js' import { cleanSocialMedia, CleanSocialMedia } from './socialmedia.js' import { CleanBasicProfile } from './skyblock/profile.js' import { cleanRank, CleanRank } from './rank.js' +import typedHypixelApi from 'typed-hypixel-api' import { undashUuid } from '../util.js' export interface CleanBasicPlayer { @@ -16,7 +16,7 @@ export interface CleanPlayer extends CleanBasicPlayer { profiles?: CleanBasicProfile[] } -export async function cleanPlayerResponse(data: HypixelApiPlayerDataResponse['player']): Promise<CleanPlayer | null> { +export async function cleanPlayerResponse(data: typedHypixelApi.PlayerDataResponse['player']): Promise<CleanPlayer | null> { // Cleans up a 'player' api response if (!data) return null // bruh diff --git a/src/cleaners/rank.ts b/src/cleaners/rank.ts index ea7579e..2ce95c8 100644 --- a/src/cleaners/rank.ts +++ b/src/cleaners/rank.ts @@ -1,4 +1,4 @@ -import { PlayerDataResponse as HypixelApiPlayerDataResponse } from 'typed-hypixel-api/build/responses/player' +import typedHypixelApi from 'typed-hypixel-api' import { colorCodeFromName, minecraftColorCodes } from '../util.js' const rankColors: { [name: string]: string } = { @@ -29,7 +29,7 @@ export function cleanRank({ rankPlusColor, rank, prefix -}: HypixelApiPlayerDataResponse['player']): CleanRank { +}: typedHypixelApi.PlayerDataResponse['player']): CleanRank { let name: string | undefined let color: string let colored: string diff --git a/src/cleaners/skyblock/bank.ts b/src/cleaners/skyblock/bank.ts index 4eace04..ac46867 100644 --- a/src/cleaners/skyblock/bank.ts +++ b/src/cleaners/skyblock/bank.ts @@ -1,3 +1,6 @@ +import typedHypixelApi from 'typed-hypixel-api' + + export interface Bank { balance?: number history: BankHistoryItem[] @@ -10,7 +13,7 @@ export interface BankHistoryItem { name: string } -export function cleanBank(data: any): Bank { +export function cleanBank(data: typedHypixelApi.SkyBlockProfile): Bank { let history: BankHistoryItem[] = [] if (data?.banking?.transactions) { diff --git a/src/cleaners/skyblock/collections.ts b/src/cleaners/skyblock/collections.ts index 7be5a9d..119e292 100644 --- a/src/cleaners/skyblock/collections.ts +++ b/src/cleaners/skyblock/collections.ts @@ -1,4 +1,5 @@ import { cleanItemId, hypixelItemNames } from './itemId.js' +import typedHypixelApi from 'typed-hypixel-api' const COLLECTIONS = { 'farming': [ @@ -95,14 +96,14 @@ function getCategory(collectionName): CollectionCategory | undefined { } } -export function cleanCollections(data: any): Collection[] { +export function cleanCollections(data: typedHypixelApi.SkyBlockProfileMember): Collection[] { // collection tiers show up like this: [ GRAVEL_3, GOLD_INGOT_2, MELON_-1, LOG_2:1_7, RAW_FISH:3_-1] // these tiers are the same for all players in a coop const playerCollectionTiersRaw: string[] = data?.unlocked_coll_tiers ?? [] - const playerCollectionTiers: { [ key: string ]: number } = {} + const playerCollectionTiers: { [key: string]: number } = {} for (const collectionTierNameValueRaw of playerCollectionTiersRaw) { - const [ collectionTierNameRaw, collectionTierValueRaw ] = collectionTierNameValueRaw.split(/_(?=-?\d+$)/) + const [collectionTierNameRaw, collectionTierValueRaw] = collectionTierNameValueRaw.split(/_(?=-?\d+$)/) const collectionName = cleanItemId(collectionTierNameRaw) // ensure it's at least 0 const collectionValue: number = Math.max(parseInt(collectionTierValueRaw), 0) @@ -114,9 +115,9 @@ export function cleanCollections(data: any): Collection[] { // collection names show up like this: { LOG: 49789, LOG:2: 26219, MUSHROOM_COLLECTION: 2923} // these values are different for each player in a coop - const playerCollectionXpsRaw: { [ key in hypixelItemNames ]: number } = data?.collection ?? {} + const playerCollectionXpsRaw: { [key in hypixelItemNames]?: number } = data?.collection ?? {} const playerCollections: Collection[] = [] - + for (const collectionNameRaw in playerCollectionXpsRaw) { const collectionXp: number = playerCollectionXpsRaw[collectionNameRaw] const collectionName = cleanItemId(collectionNameRaw) diff --git a/src/cleaners/skyblock/election.ts b/src/cleaners/skyblock/election.ts index 9094e2d..1688c66 100644 --- a/src/cleaners/skyblock/election.ts +++ b/src/cleaners/skyblock/election.ts @@ -1,3 +1,6 @@ +import typedHypixelApi from 'typed-hypixel-api' + + const candidateColors = [ '4', 'a', '3', 'e', '5', ] @@ -27,7 +30,10 @@ export interface ElectionData { } | null } -function cleanCandidate(data: any, index: number): Candidate { +function cleanCandidate( + data: typedHypixelApi.Candidate & { votes: number }, + index: number +): Candidate { return { name: data.name, perks: data.perks.map(perk => ({ @@ -39,7 +45,7 @@ function cleanCandidate(data: any, index: number): Candidate { } } -export async function cleanElectionResponse(data: any): Promise<ElectionData> { +export async function cleanElectionResponse(data: typedHypixelApi.SkyBlockElectionResponse): Promise<ElectionData> { const previousCandidates = data.mayor.election.candidates.map(cleanCandidate) return { lastUpdated: data.lastUpdated, diff --git a/src/cleaners/skyblock/fairysouls.ts b/src/cleaners/skyblock/fairysouls.ts index 67de0dd..92b1eff 100644 --- a/src/cleaners/skyblock/fairysouls.ts +++ b/src/cleaners/skyblock/fairysouls.ts @@ -1,3 +1,4 @@ +import typedHypixelApi from 'typed-hypixel-api' import * as constants from '../../constants.js' export interface FairySouls { @@ -9,7 +10,7 @@ export interface FairySouls { max: number } -export async function cleanFairySouls(data: any): Promise<FairySouls> { +export async function cleanFairySouls(data: typedHypixelApi.SkyBlockProfileMember): Promise<FairySouls> { const { max_fairy_souls } = await constants.fetchConstantValues() return { total: data?.fairy_souls_collected ?? 0, diff --git a/src/cleaners/skyblock/inventory.ts b/src/cleaners/skyblock/inventory.ts index 0ebb581..9e5ee29 100644 --- a/src/cleaners/skyblock/inventory.ts +++ b/src/cleaners/skyblock/inventory.ts @@ -1,6 +1,7 @@ -// maybe todo?: create a fast replacement for prismarine-nbt +import typedHypixelApi from 'typed-hypixel-api' import * as nbt from 'prismarine-nbt' + function base64decode(base64: string): Buffer { return Buffer.from(base64, 'base64') } @@ -19,7 +20,7 @@ interface Item { reforge?: string anvilUses?: number timestamp?: string - enchantments?: { [ name: string ]: number } + enchantments?: { [name: string]: number } headTexture?: string } @@ -98,9 +99,9 @@ export const INVENTORIES = { personal_vault: 'personal_vault_contents' } -export type Inventories = { [name in keyof typeof INVENTORIES ]: Item[] } +export type Inventories = { [name in keyof typeof INVENTORIES]: Item[] } -export async function cleanInventories(data: any): Promise<Inventories> { +export async function cleanInventories(data: typedHypixelApi.SkyBlockProfileMember): Promise<Inventories> { const cleanInventories: any = {} for (const cleanInventoryName in INVENTORIES) { const hypixelInventoryName = INVENTORIES[cleanInventoryName] diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts index e187beb..aa102e1 100644 --- a/src/cleaners/skyblock/member.ts +++ b/src/cleaners/skyblock/member.ts @@ -1,4 +1,3 @@ -import { ProfileMember as HypixelApiProfileMember } from 'typed-hypixel-api/build/responses/skyblock/_profile_member' import { cleanCollections, Collection } from './collections.js' import { cleanInventories, Inventories } from './inventory.js' import { cleanFairySouls, FairySouls } from './fairysouls.js' @@ -11,6 +10,7 @@ import { AccountCustomization } from '../../database.js' import { cleanVisitedZones, Zone } from './zones.js' import { cleanSkills, Skill } from './skills.js' import * as cached from '../../hypixelCached.js' +import typedHypixelApi from 'typed-hypixel-api' import * as constants from '../../constants.js' import { Included } from '../../hypixel.js' import { CleanPlayer } from '../player.js' @@ -41,7 +41,7 @@ export interface CleanMember extends CleanBasicMember { left: boolean } -export async function cleanSkyBlockProfileMemberResponseBasic(member: any): Promise<CleanBasicMember | null> { +export async function cleanSkyBlockProfileMemberResponseBasic(member: typedHypixelApi.SkyBlockProfileMember & { uuid: string }): Promise<CleanBasicMember | null> { const player = await cached.fetchPlayer(member.uuid) if (!player) return null return { @@ -54,7 +54,7 @@ export async function cleanSkyBlockProfileMemberResponseBasic(member: any): Prom } /** Cleans up a member (from skyblock/profile) */ -export async function cleanSkyBlockProfileMemberResponse(member: HypixelApiProfileMember & { uuid: string }, profileId?: string, included: Included[] | undefined = undefined): Promise<CleanMember | null> { +export async function cleanSkyBlockProfileMemberResponse(member: typedHypixelApi.SkyBlockProfileMember & { uuid: string }, profileId?: string, included: Included[] | undefined = undefined): Promise<CleanMember | null> { // profiles.members[] const inventoriesIncluded = included === undefined || included.includes('inventories') const player = await cached.fetchPlayer(member.uuid) diff --git a/src/cleaners/skyblock/minions.ts b/src/cleaners/skyblock/minions.ts index 2e51896..c77b6c5 100644 --- a/src/cleaners/skyblock/minions.ts +++ b/src/cleaners/skyblock/minions.ts @@ -1,5 +1,6 @@ -import { maxMinion } from '../../hypixel.js' +import typedHypixelApi from 'typed-hypixel-api' import * as constants from '../../constants.js' +import { maxMinion } from '../../hypixel.js' export interface CleanMinion { name: string, @@ -11,7 +12,7 @@ export interface CleanMinion { * Clean the minions provided by Hypixel * @param minionsRaw The minion data provided by the Hypixel API */ -export async function cleanMinions(member: any): Promise<CleanMinion[]> { +export async function cleanMinions(member: typedHypixelApi.SkyBlockProfileMember): Promise<CleanMinion[]> { const minions: CleanMinion[] = [] const processedMinionNames: Set<string> = new Set() diff --git a/src/cleaners/skyblock/objectives.ts b/src/cleaners/skyblock/objectives.ts index 3427f1f..2443f77 100644 --- a/src/cleaners/skyblock/objectives.ts +++ b/src/cleaners/skyblock/objectives.ts @@ -1,9 +1,12 @@ +import typedHypixelApi from 'typed-hypixel-api' + + export interface Objective { name: string completed: boolean } -export function cleanObjectives(data: any): Objective[] { +export function cleanObjectives(data: typedHypixelApi.SkyBlockProfileMember): Objective[] { const rawObjectives = data?.objectives || {} const objectives: Objective[] = [] for (const rawObjectiveName in rawObjectives) { diff --git a/src/cleaners/skyblock/profile.ts b/src/cleaners/skyblock/profile.ts index 03ff2eb..fe9b558 100644 --- a/src/cleaners/skyblock/profile.ts +++ b/src/cleaners/skyblock/profile.ts @@ -1,6 +1,6 @@ import { CleanBasicMember, CleanMember, cleanSkyBlockProfileMemberResponse, cleanSkyBlockProfileMemberResponseBasic } from './member.js' -import { SkyBlockProfilesResponse as HypixelApiSkyBlockProfilesResponse } from 'typed-hypixel-api/build/responses/skyblock/profiles' import { CleanMinion, combineMinionArrays, countUniqueMinions } from './minions.js' +import typedHypixelApi from 'typed-hypixel-api' import * as constants from '../../constants.js' import { ApiOptions } from '../../hypixel.js' import { Bank, cleanBank } from './bank.js' @@ -26,22 +26,22 @@ export interface CleanFullProfileBasicMembers extends CleanProfile { } /** Return a `CleanProfile` instead of a `CleanFullProfile`, useful when we need to get members but don't want to waste much ram */ -export async function cleanSkyblockProfileResponseLighter(data): Promise<CleanProfile> { +export async function cleanSkyblockProfileResponseLighter(data: typedHypixelApi.SkyBlockProfile | typedHypixelApi.SkyBlockProfilesResponse['profiles'][number]): Promise<CleanProfile> { // We use Promise.all so it can fetch all the usernames at once instead of waiting for the previous promise to complete const promises: Promise<CleanBasicMember | null>[] = [] for (const memberUUID in data.members) { const memberRaw = data.members[memberUUID] - memberRaw.uuid = memberUUID + const memberRawWithUuid = { ...memberRaw, uuid: memberUUID } // we pass an empty array to make it not check stats - promises.push(cleanSkyBlockProfileMemberResponseBasic(memberRaw)) + promises.push(cleanSkyBlockProfileMemberResponseBasic(memberRawWithUuid)) } const cleanedMembers: CleanBasicMember[] = (await Promise.all(promises)).filter(m => m) as CleanBasicMember[] return { uuid: data.profile_id, - name: data.cute_name, + name: 'cute_name' in data ? data.cute_name : undefined, members: cleanedMembers, } } @@ -49,12 +49,15 @@ export async function cleanSkyblockProfileResponseLighter(data): Promise<CleanPr /** * This function is somewhat costly and shouldn't be called often. Use cleanSkyblockProfileResponseLighter if you don't need all the data */ -export async function cleanSkyblockProfileResponse<O extends ApiOptions>(data: HypixelApiSkyBlockProfilesResponse['profiles'][number], options?: O): Promise<(O['basic'] extends true ? CleanProfile : CleanFullProfile) | null> { +export async function cleanSkyblockProfileResponse<O extends ApiOptions>( + data: typedHypixelApi.SkyBlockProfile | typedHypixelApi.SkyBlockProfilesResponse['profiles'][number], + options?: O +): Promise<(O['basic'] extends true ? CleanProfile : CleanFullProfile) | null> { // We use Promise.all so it can fetch all the users at once instead of waiting for the previous promise to complete const promises: Promise<CleanMember | null>[] = [] if (!data) return null - const profileId: string = data.profile_id + const profileId = data.profile_id for (const memberUUID in data.members) { const memberRaw = data.members[memberUUID] @@ -75,7 +78,7 @@ export async function cleanSkyblockProfileResponse<O extends ApiOptions>(data: H if (options?.basic) { const cleanProfile: CleanProfile = { uuid: profileId, - name: data.cute_name, + name: 'cute_name' in data ? data.cute_name : undefined, members: cleanedMembers, } // we have to do this because of the basic checking typing @@ -98,7 +101,7 @@ export async function cleanSkyblockProfileResponse<O extends ApiOptions>(data: H // return more detailed info const cleanFullProfile: CleanFullProfile = { uuid: data.profile_id, - name: data.cute_name, + name: 'cute_name' in data ? data.cute_name : undefined, members: cleanedMembers, bank: cleanBank(data), minions: minions, diff --git a/src/cleaners/skyblock/profiles.ts b/src/cleaners/skyblock/profiles.ts index ddab078..f046e22 100644 --- a/src/cleaners/skyblock/profiles.ts +++ b/src/cleaners/skyblock/profiles.ts @@ -2,10 +2,9 @@ import { HypixelPlayerStatsSkyBlockProfiles } from '../../hypixelApi.js' import { CleanBasicProfile, CleanFullProfile, - CleanProfile, cleanSkyblockProfileResponse } from './profile.js' -import { SkyBlockProfilesResponse } from 'typed-hypixel-api/build/responses/skyblock/profiles' +import typedHypixelApi from 'typed-hypixel-api' export function cleanPlayerSkyblockProfiles(rawProfiles: HypixelPlayerStatsSkyBlockProfiles | undefined): CleanBasicProfile[] { if (!rawProfiles) return [] @@ -21,7 +20,7 @@ export function cleanPlayerSkyblockProfiles(rawProfiles: HypixelPlayerStatsSkyBl } /** Convert an array of raw profiles into clean profiles */ -export async function cleanSkyblockProfilesResponse(data: SkyBlockProfilesResponse['profiles']): Promise<CleanFullProfile[]> { +export async function cleanSkyblockProfilesResponse(data: typedHypixelApi.SkyBlockProfilesResponse['profiles']): Promise<CleanFullProfile[]> { const promises: Promise<CleanFullProfile | null>[] = [] for (const profile of data) { promises.push(cleanSkyblockProfileResponse(profile)) diff --git a/src/cleaners/skyblock/skills.ts b/src/cleaners/skyblock/skills.ts index 886c59c..c69acd0 100644 --- a/src/cleaners/skyblock/skills.ts +++ b/src/cleaners/skyblock/skills.ts @@ -1,4 +1,4 @@ -import { fetchSkillXp, fetchSkillXpEasier } from '../../constants.js' +import typedHypixelApi from 'typed-hypixel-api' export interface Skill { name: string @@ -13,7 +13,7 @@ export interface Skill { // the highest level you can have in each skill // numbers taken from https://hypixel-skyblock.fandom.com/wiki/Skills -const skillsMaxLevel: { [ key: string ]: number } = { +const skillsMaxLevel: { [key: string]: number } = { farming: 60, mining: 60, combat: 60, @@ -89,8 +89,8 @@ const skillXpTable = [ 97972425, 104672425, 111672425 // 60 - ] - +] + const skillXpTableEasier = [ 50, // 1 @@ -135,14 +135,14 @@ export function levelForSkillXp(xp: number, maxLevel: number) { return skillLevel === -1 ? 0 : xpTable.length - skillLevel } -export async function cleanSkills(data: any): Promise<Skill[]> { +export async function cleanSkills(data: typedHypixelApi.SkyBlockProfileMember): Promise<Skill[]> { const skills: Skill[] = [] for (const item in data) { if (item.startsWith('experience_skill_')) { - const skillName = item.substr('experience_skill_'.length) + const skillName = item.slice('experience_skill_'.length) // the amount of total xp you have in this skill - const skillXp = data[item] + const skillXp: number = data[item] const skillMaxLevel = skillsMaxLevel[skillName] ?? skillsDefaultMaxLevel diff --git a/src/cleaners/skyblock/slayers.ts b/src/cleaners/skyblock/slayers.ts index f4d203e..782ec95 100644 --- a/src/cleaners/skyblock/slayers.ts +++ b/src/cleaners/skyblock/slayers.ts @@ -1,3 +1,5 @@ +import typedHypixelApi from 'typed-hypixel-api' + export const slayerLevels = 5 const SLAYER_NAMES = { @@ -29,7 +31,7 @@ export interface SlayerData { bosses: Slayer[] } -export function cleanSlayers(data: any): SlayerData { +export function cleanSlayers(data: typedHypixelApi.SkyBlockProfileMember): SlayerData { const slayers: Slayer[] = [] const slayersDataRaw = data?.slayer_bosses diff --git a/src/cleaners/skyblock/stats.ts b/src/cleaners/skyblock/stats.ts index cce1561..645f879 100644 --- a/src/cleaners/skyblock/stats.ts +++ b/src/cleaners/skyblock/stats.ts @@ -1,4 +1,7 @@ -const statCategories: { [ key: string ]: string[] | null } = { // sorted in order of importance +import typedHypixelApi from 'typed-hypixel-api' + + +const statCategories: { [key: string]: string[] | null } = { // sorted in order of importance 'deaths': ['deaths_', 'deaths'], 'kills': ['kills_', 'kills'], 'fishing': ['items_fished_', 'items_fished', 'shredder_'], @@ -76,7 +79,7 @@ export interface StatItem { } export function getStatUnit(name: string): string | null { - for (const [ unitName, statMatchers ] of Object.entries(statUnits)) { + for (const [unitName, statMatchers] of Object.entries(statUnits)) { for (const statMatch of statMatchers) { let trailingEnd = statMatch[0] === '_' let trailingStart = statMatch.substr(-1) === '_' @@ -92,7 +95,7 @@ export function getStatUnit(name: string): string | null { } -export function cleanProfileStats(data: any): StatItem[] { +export function cleanProfileStats(data: typedHypixelApi.SkyBlockProfileMember): StatItem[] { // TODO: add type for statsRaw (probably in hypixelApi.ts since its coming from there) const stats: StatItem[] = [] diff --git a/src/cleaners/skyblock/zones.ts b/src/cleaners/skyblock/zones.ts index b07c542..556a2e7 100644 --- a/src/cleaners/skyblock/zones.ts +++ b/src/cleaners/skyblock/zones.ts @@ -1,3 +1,4 @@ +import typedHypixelApi from 'typed-hypixel-api' import * as constants from '../../constants.js' export interface Zone { @@ -6,7 +7,7 @@ export interface Zone { } -export async function cleanVisitedZones(data: any): Promise<Zone[]> { +export async function cleanVisitedZones(data: typedHypixelApi.SkyBlockProfileMember): Promise<Zone[]> { const rawZones = data?.visited_zones || [] // TODO: store all the zones that exist in SkyBlock, add add those to the array with visited being false const zones: Zone[] = [] @@ -19,7 +20,7 @@ export async function cleanVisitedZones(data: any): Promise<Zone[]> { visited: rawZones.includes(rawZoneName) }) } - + // if this user somehow has a zone that we don't know about, just add it to zones for (const rawZoneName of rawZones) { if (!knownZones.includes(rawZoneName)) { 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]>> } |