From 81491e7fba63fd0a5492ca5c8916e5998a70256b Mon Sep 17 00:00:00 2001
From: DaInfLoop <github@dainfloop.is-a.dev>
Date: Sun, 9 Mar 2025 14:45:04 +0000
Subject: [PATCH] Change leaderboard to use PP instead of score

credits to @srizan10 for idea
---
 index.ts | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/index.ts b/index.ts
index d4b95d8..18363b4 100644
--- a/index.ts
+++ b/index.ts
@@ -267,10 +267,10 @@ async function cacheStuff(): Promise<void> {
             id: user.id,
             slackId: osuUsers.find(v => v[0] == user.id)![1],
             score: {
-                osu: user.statistics_rulesets.osu?.total_score || 0,
-                taiko: user.statistics_rulesets.taiko?.total_score || 0,
-                fruits: user.statistics_rulesets.fruits?.total_score || 0,
-                mania: user.statistics_rulesets.mania?.total_score || 0,
+                osu: Math.floor(user.statistics_rulesets.osu?.pp) || 0,
+                taiko: Math.floor(user.statistics_rulesets.taiko?.pp) || 0,
+                fruits: Math.floor(user.statistics_rulesets.fruits?.pp) || 0,
+                mania: Math.floor(user.statistics_rulesets.mania?.pp) || 0,
             }
         })))
     }
@@ -1312,7 +1312,10 @@ const processQueue = async () => {
             skin: 'default',
             username: job.playerName,
             showDanserLogo: false,
-            resolution: '1280x720'
+            resolution: '1280x720',
+            introBGDim: 100,
+            inGameBGDim: 100,
+            breakBGDim: 100
         })
 
         console.log(render)
@@ -1424,12 +1427,15 @@ app.event("message", async (ctx) => {
     replayFile.write(replayBuffer);
     replayFile.end();
 
-    addToQueue({
-        md5: _replay.replayMD5,
-        playerName: _replay.playerName,
-        ts: ts,
-        userId: ctx.context.userId!
-    })
+
+    replayFile.on('finish', () => {
+        addToQueue({
+            md5: _replay.replayMD5,
+            playerName: _replay.playerName,
+            ts: ts,
+            userId: ctx.context.userId!
+        })
+    });
 })
 
     ; (async () => {