From 6b2bdd5b86eb0ebdf67b50bf5f2dcf74044fe914 Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 20 Apr 2022 19:16:16 -0500 Subject: store api ids in skyblock-constants --- src/cleaners/skyblock/harp.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/cleaners/skyblock/harp.ts') 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 -- cgit