From 83bcca7f6925db6edbe28bf5f6c7f0d0d84fc12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Thu, 6 Jun 2024 19:40:37 -0500 Subject: [PATCH] fix: no participation edge case --- src/commands/rating.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/commands/rating.tsx b/src/commands/rating.tsx index ce5b919b5..885baa713 100644 --- a/src/commands/rating.tsx +++ b/src/commands/rating.tsx @@ -85,7 +85,15 @@ export const ratingCommand = new Promise((resolve) => { const statsA = leaderboard ? leaderboard.entries[statsIndex!] : null; const positionA = leaderboard ? statsIndex! + 1 : undefined; const statsB1 = accountInfo.statistics.rating!; - const [statsB2] = (await getRatingNeighbors(region, id, 0)).neighbors; + const statsB2Array = (await getRatingNeighbors(region, id, 0)).neighbors; + + if (statsB2Array === undefined) { + return translate('bot.commands.rating.errors.no_participation', [ + markdownEscape(accountInfo.nickname), + ]); + } + + const [statsB2] = statsB2Array; const league = getLeagueFromScore(statsB2.score); if (!statsA) {