aboutsummaryrefslogtreecommitdiff
path: root/src/database.ts
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-05-31 19:38:29 -0500
committermat <github@matdoes.dev>2021-05-31 19:38:29 -0500
commitf1e85074ce32f62a7b44d5bd6c8399d99f2368c5 (patch)
tree6b16dad9a058b8aca1f984f1a8132fb19837d5d8 /src/database.ts
parent7278b0563cb7ac7d76b925af4668946ee5784c6e (diff)
downloadskyblock-api-f1e85074ce32f62a7b44d5bd6c8399d99f2368c5.tar.gz
skyblock-api-f1e85074ce32f62a7b44d5bd6c8399d99f2368c5.tar.bz2
skyblock-api-f1e85074ce32f62a7b44d5bd6c8399d99f2368c5.zip
add leaderboard infos
Diffstat (limited to 'src/database.ts')
-rw-r--r--src/database.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/database.ts b/src/database.ts
index 5ee29d4..577bd6a 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -100,6 +100,13 @@ let profileLeaderboardsCollection: Collection<DatabaseProfileLeaderboardItem>
let sessionsCollection: Collection<SessionSchema>
let accountsCollection: Collection<AccountSchema>
+
+const leaderboardInfos: { [ leaderboardName: string ]: string } = {
+ highest_crit_damage: 'This leaderboard is capped at the integer limit because Hypixel, look at <a href="/leaderboard/highest_critical_damage">Highest critical damage</a> instead.',
+ highest_critical_damage: 'uhhhhh yeah idk either'
+}
+
+
async function connect(): Promise<void> {
if (!process.env.db_uri)
return console.warn('Warning: db_uri was not found in .env. Features that utilize the database such as leaderboards won\'t work.')
@@ -353,12 +360,14 @@ interface MemberLeaderboard {
name: string
unit?: string
list: MemberLeaderboardItem[]
+ info?: string
}
interface ProfileLeaderboard {
name: string
unit?: string
list: ProfileLeaderboardItem[]
+ info?: string
}
@@ -415,11 +424,17 @@ export async function fetchProfileLeaderboard(name: string): Promise<ProfileLead
/** Fetch a leaderboard */
export async function fetchLeaderboard(name: string): Promise<MemberLeaderboard|ProfileLeaderboard> {
const profileLeaderboards = await fetchAllProfileLeaderboardAttributes()
+ let leaderboard: MemberLeaderboard|ProfileLeaderboard
if (profileLeaderboards.includes(name)) {
- return await fetchProfileLeaderboard(name)
+ leaderboard = await fetchProfileLeaderboard(name)
} else {
- return await fetchMemberLeaderboard(name)
+ leaderboard = await fetchMemberLeaderboard(name)
}
+
+ if (leaderboardInfos[name])
+ leaderboard.info = leaderboardInfos[name]
+
+ return leaderboard
}
/** Get the leaderboard positions a member is on. This may take a while depending on whether stuff is cached */