diff options
author | mat <github@matdoes.dev> | 2022-04-10 18:54:48 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-04-10 18:54:48 -0500 |
commit | d0f7262b1b132f990d7cdc9c88eda927515723ad (patch) | |
tree | 4734c152db4097ec356120dd918664024f88bd1f /src/cleaners | |
parent | 26aa581d96ec0db3644bb930feb8cd5bb97cfc70 (diff) | |
download | skyblock-api-d0f7262b1b132f990d7cdc9c88eda927515723ad.tar.gz skyblock-api-d0f7262b1b132f990d7cdc9c88eda927515723ad.tar.bz2 skyblock-api-d0f7262b1b132f990d7cdc9c88eda927515723ad.zip |
Cache usernames and ranks in leaderboards in db
Diffstat (limited to 'src/cleaners')
-rw-r--r-- | src/cleaners/rank.ts | 6 | ||||
-rw-r--r-- | src/cleaners/skyblock/profiles.ts | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/cleaners/rank.ts b/src/cleaners/rank.ts index 2ce95c8..a9bc255 100644 --- a/src/cleaners/rank.ts +++ b/src/cleaners/rank.ts @@ -1,7 +1,7 @@ import typedHypixelApi from 'typed-hypixel-api' import { colorCodeFromName, minecraftColorCodes } from '../util.js' -const rankColors: { [name: string]: string } = { +export const RANK_COLORS: { [name: string]: string } = { 'NONE': '7', 'VIP': 'a', 'VIP+': 'a', @@ -69,8 +69,8 @@ export function cleanRank({ } const plusColor = rankPlusColor ? colorCodeFromName(rankPlusColor) : null - color = minecraftColorCodes[rankColors[name]] - let rankColorPrefix = rankColors[name] ? '§' + rankColors[name] : '' + color = minecraftColorCodes[RANK_COLORS[name]] + let rankColorPrefix = RANK_COLORS[name] ? '§' + RANK_COLORS[name] : '' // the text is white, but only in the prefix if (name === 'YOUTUBE') diff --git a/src/cleaners/skyblock/profiles.ts b/src/cleaners/skyblock/profiles.ts index f046e22..519c6d5 100644 --- a/src/cleaners/skyblock/profiles.ts +++ b/src/cleaners/skyblock/profiles.ts @@ -20,7 +20,9 @@ export function cleanPlayerSkyblockProfiles(rawProfiles: HypixelPlayerStatsSkyBl } /** Convert an array of raw profiles into clean profiles */ -export async function cleanSkyblockProfilesResponse(data: typedHypixelApi.SkyBlockProfilesResponse['profiles']): Promise<CleanFullProfile[]> { +export async function cleanSkyblockProfilesResponse(data: typedHypixelApi.SkyBlockProfilesResponse['profiles']): Promise<CleanFullProfile[] | null> { + if (data === null) return null + const promises: Promise<CleanFullProfile | null>[] = [] for (const profile of data) { promises.push(cleanSkyblockProfileResponse(profile)) |