aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts
diff options
context:
space:
mode:
authorGravatar Shom770 <[email protected]>2021-12-28 00:37:50 -0500
committerGravatar Shom770 <[email protected]>2022-02-09 18:13:37 -0500
commit736cddce6b84cd8df09da1904c20e503dc4a46e1 (patch)
tree12799d9b8242975dac4c5350d1a091439dccc7c8 /bot/exts
parentdisplay error when something goes wrong with .trivianight load (diff)
improving ordinal number usage in _scoreboard.ScoreboardView._get_rank
Diffstat (limited to 'bot/exts')
-rw-r--r--bot/exts/events/trivianight/_scoreboard.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/bot/exts/events/trivianight/_scoreboard.py b/bot/exts/events/trivianight/_scoreboard.py
index d9107dca..6f95f22c 100644
--- a/bot/exts/events/trivianight/_scoreboard.py
+++ b/bot/exts/events/trivianight/_scoreboard.py
@@ -91,19 +91,31 @@ class ScoreboardView(View):
color=Colours.soft_red
)
- suffixes = {"1": "st", "2": "nd", "3": "rd"}
+ suffix = ["th", "st", "nd", "rd", "th"][min(int(points_rank) % 10, 4)]
+ if (int(points_rank) % 100) in {11, 12, 13}:
+ suffix = "th"
+
+ points_rank = str(points_rank) + suffix
+
rank_embed.add_field(
name="Total Points",
value=(
- f"You got {points_rank}{'th' if not (suffix := suffixes.get(points_rank[-1])) else suffix} place"
+ f"You got {points_rank} place"
f" with {self.points[member.id]:.1f} points."
),
inline=False
)
+
+ suffix = ["th", "st", "nd", "rd", "th"][min(int(speed_rank) % 10, 4)]
+ if (int(speed_rank) % 100) in {11, 12, 13}:
+ suffix = "th"
+
+ speed_rank = str(speed_rank) + suffix
+
rank_embed.add_field(
name="Average Speed",
value=(
- f"You got {speed_rank}{'th' if not (suffix := suffixes.get(speed_rank[-1])) else suffix} place"
+ f"You got {speed_rank} place"
f" with a time of {(self.speed[member.id][1] / self.speed[member.id][0]):.1f} seconds."
),
inline=False