Skip to content

Commit 0d8b2d5

Browse files
authored
Quick-fix for crash
1 parent d073289 commit 0d8b2d5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/index.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,22 @@ async function updateRankingsChannel(statsList: Map<string, Stats[]>): Promise<v
150150
*/
151151
async function getStats(key: string): Promise<Stats> {
152152
let result = JSON.parse(<string>await redisClient.get(key))
153+
154+
// For some reason keys can exist for players with no rankings
155+
if (!result) {
156+
result = {
157+
name: "",
158+
score: 0,
159+
kills: 0,
160+
deaths: 0,
161+
bounty_kills: 0,
162+
flag_attempts: 0,
163+
flag_captures: 0,
164+
hp_healed: 0,
165+
place: Infinity,
166+
}
167+
}
168+
153169
return {
154170
name: "",
155171
score: result.score || 0,
@@ -159,7 +175,7 @@ async function getStats(key: string): Promise<Stats> {
159175
flag_attempts: result.flag_attempts || 0,
160176
flag_captures: result.flag_captures || 0,
161177
hp_healed: result.hp_healed || 0,
162-
place: NaN
178+
place: NaN,
163179
}
164180
}
165181

0 commit comments

Comments
 (0)