aboutsummaryrefslogtreecommitdiff
path: root/src/cleaners/skyblock/essence.ts
blob: 19f43c1c26212bad026649f97455edc02f5b879e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import typedHypixelApi from 'typed-hypixel-api'

interface EssenceType {
	id: string
	amount: number
}

export interface Essence {
	types: EssenceType[]
}

export function cleanEssence(data: typedHypixelApi.SkyBlockProfileMember): Essence {
	const essences: EssenceType[] = []

	for (const [id, amount] of Object.entries(data ?? {})) {
		if (id.startsWith('essence_')) {
			essences.push({
				id: id.replace(/^essence_/, ''),
				amount: amount ?? 0,
			})
		}
	}

	return {
		types: essences,
	}
}