diff --git a/apps/discord-bot/src/commands/parkour/parkour.profile.tsx b/apps/discord-bot/src/commands/parkour/parkour.profile.tsx index b5c9d185a..bfd7bfa48 100644 --- a/apps/discord-bot/src/commands/parkour/parkour.profile.tsx +++ b/apps/discord-bot/src/commands/parkour/parkour.profile.tsx @@ -16,6 +16,9 @@ interface ParkourProfileProps extends BaseProfileProps { gameIcons: Record; } +const hasTime = (t: unknown): t is number => + typeof t === "number" && !Number.isNaN(t); + export const ParkourProfile = ({ skin, player, @@ -28,8 +31,15 @@ export const ParkourProfile = ({ const { parkour } = player.stats; const times: [GameId, any][] = Object.entries(parkour) - .sort((a, b) => (a[1] || Number.MAX_VALUE) - (b[1] || Number.MAX_VALUE)) - .map(([field, time]) => [field as GameId, time ? formatTime(time) : "N/A"]); + .sort( + (a, b) => + (hasTime(a[1]) ? a[1] : Number.MAX_VALUE) - + (hasTime(b[1]) ? b[1] : Number.MAX_VALUE), + ) + .map(([field, time]) => [ + field as GameId, + hasTime(time) ? formatTime(time) : "N/A", + ]); return (