diff options
author | mat <github@matdoes.dev> | 2022-04-20 19:16:16 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-04-20 19:16:16 -0500 |
commit | 6b2bdd5b86eb0ebdf67b50bf5f2dcf74044fe914 (patch) | |
tree | 986d1f11c1267d9598a15f6031aeee1e2925ea63 /src/cleaners/skyblock/harp.ts | |
parent | 5712e10eec2c9fa881bdf19295808404c56f7d33 (diff) | |
download | skyblock-api-6b2bdd5b86eb0ebdf67b50bf5f2dcf74044fe914.tar.gz skyblock-api-6b2bdd5b86eb0ebdf67b50bf5f2dcf74044fe914.tar.bz2 skyblock-api-6b2bdd5b86eb0ebdf67b50bf5f2dcf74044fe914.zip |
store api ids in skyblock-constants
Diffstat (limited to 'src/cleaners/skyblock/harp.ts')
-rw-r--r-- | src/cleaners/skyblock/harp.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/cleaners/skyblock/harp.ts b/src/cleaners/skyblock/harp.ts index b1ec905..c38013e 100644 --- a/src/cleaners/skyblock/harp.ts +++ b/src/cleaners/skyblock/harp.ts @@ -1,5 +1,5 @@ import typedHypixelApi from 'typed-hypixel-api' -import { fetchHarpSongs } from '../../constants.js' +import * as constants from '../../constants.js' export interface HarpSong { id: string @@ -26,11 +26,14 @@ export async function cleanHarp(data: typedHypixelApi.SkyBlockProfileMember): Pr const harpQuestData = data.harp_quest ?? {} const songs: HarpSong[] = [] - const allHarpSongNames = await fetchHarpSongs() + let songIds: string[] = [] + + const allHarpSongIds = await constants.fetchHarpSongs() for (const item in data.harp_quest) { if (item.startsWith('song_') && item.endsWith('_best_completion')) { const apiSongName = item.slice('song_'.length, -'_best_completion'.length) + songIds.push(apiSongName) const songName = renamedSongs[apiSongName] ?? apiSongName songs.push({ id: songName, @@ -41,10 +44,12 @@ export async function cleanHarp(data: typedHypixelApi.SkyBlockProfileMember): Pr } } - const missingHarpSongNames = allHarpSongNames.filter(songName => !songs.find(song => (renamedSongs[song.id] ?? song.id) === songName)) - for (const songName of missingHarpSongNames) { + constants.addHarpSongs(songIds) + + const missingHarpSongId = allHarpSongIds.filter(songId => !songIds.includes(songId)) + for (const songId of missingHarpSongId) { songs.push({ - id: renamedSongs[songName] ?? songName, + id: renamedSongs[songId] ?? songId, completions: 0, perfectCompletions: 0, progress: 0 |