aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cleaners/skyblock/slayers.ts11
-rw-r--r--src/database.ts10
2 files changed, 15 insertions, 6 deletions
diff --git a/src/cleaners/skyblock/slayers.ts b/src/cleaners/skyblock/slayers.ts
index 782ec95..b5dda0b 100644
--- a/src/cleaners/skyblock/slayers.ts
+++ b/src/cleaners/skyblock/slayers.ts
@@ -1,6 +1,5 @@
import typedHypixelApi from 'typed-hypixel-api'
-export const slayerLevels = 5
const SLAYER_NAMES = {
spider: 'tarantula',
@@ -9,6 +8,14 @@ const SLAYER_NAMES = {
enderman: 'voidgloom_seraph'
} as const
+// todo: put this in skyblock-constants since it can be determined from other people's profiles
+export const SLAYER_TIERS: Record<keyof typeof SLAYER_NAMES, number> = {
+ spider: 4,
+ zombie: 5,
+ enderman: 4,
+ wolf: 4
+}
+
type SlayerName = (typeof SLAYER_NAMES)[keyof typeof SLAYER_NAMES]
interface SlayerTier {
@@ -75,7 +82,7 @@ export function cleanSlayers(data: typedHypixelApi.SkyBlockProfileMember): Slaye
}
// if the slayer tier length is less than the max, add more empty ones
- while (slayerTiers.length < slayerLevels)
+ while (slayerTiers.length < SLAYER_TIERS[slayerName])
slayerTiers.push({
tier: slayerTiers.length + 1,
kills: 0
diff --git a/src/database.ts b/src/database.ts
index 394b58b..9c2978b 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -4,9 +4,9 @@
import { categorizeStat, getStatUnit } from './cleaners/skyblock/stats.js'
import { CleanFullProfile } from './cleaners/skyblock/profile.js'
-import { slayerLevels } from './cleaners/skyblock/slayers.js'
+import { SLAYER_TIERS } from './cleaners/skyblock/slayers.js'
+import { Collection, Db, MongoClient, WithId } from 'mongodb'
import { CleanMember } from './cleaners/skyblock/member.js'
-import { Collection, Db, Filter, MongoClient, WithId } from 'mongodb'
import { CleanPlayer } from './cleaners/player.js'
import * as cached from './hypixelCached.js'
import * as constants from './constants.js'
@@ -14,8 +14,8 @@ import { shuffle, sleep } from './util.js'
import * as discord from './discord.js'
import NodeCache from 'node-cache'
import { v4 as uuid4 } from 'uuid'
-import Queue from 'queue-promise'
import { debug } from './index.js'
+import Queue from 'queue-promise'
// don't update the user for 3 minutes
const recentlyUpdated = new NodeCache({
@@ -256,7 +256,7 @@ export async function fetchSlayerLeaderboards(): Promise<string[]> {
for (const slayerNameRaw of rawSlayerNames) {
leaderboardNames.push(`slayer_${slayerNameRaw}_total_xp`)
leaderboardNames.push(`slayer_${slayerNameRaw}_total_kills`)
- for (let slayerTier = 1; slayerTier <= slayerLevels; slayerTier++) {
+ for (let slayerTier = 1; slayerTier <= SLAYER_TIERS[slayerNameRaw]; slayerTier++) {
leaderboardNames.push(`slayer_${slayerNameRaw}_${slayerTier}_kills`)
}
}
@@ -652,6 +652,8 @@ async function getApplicableProfileLeaderboardAttributes(profile: CleanFullProfi
* deleted. This only makes one database call if there's no profiles to delete.
*/
export async function removeDeletedProfilesFromLeaderboards(memberUuid: string, profilesUuids: string[]) {
+ if (!client) return
+
const leaderboardProfilesInDatabase = (await (await memberLeaderboardsCollection.find({
uuid: memberUuid,
})).toArray())