From 646bf230a6f0ea95279d51c1e21833427566d8f2 Mon Sep 17 00:00:00 2001 From: Lemon Rose Date: Sun, 15 Oct 2023 22:08:06 +0530 Subject: [PATCH] [BattleRoyale] use global name or display name --- battleroyale/game.py | 6 +++--- battleroyale/views.py | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/battleroyale/game.py b/battleroyale/game.py index 37f25087..a752f281 100644 --- a/battleroyale/game.py +++ b/battleroyale/game.py @@ -112,8 +112,8 @@ async def start( emoji: discord.PartialEmoji = random.choice(EMOJIS) prompts += "\n" + random.choice(PROMPTS).format( emoji=custom_emoji if custom_emoji else emoji, - killer=f"**{killer.display_name}**", - killed=f"**{killed.display_name}**", + killer=f"**{killer.global_name or killer.display_name}**", + killed=f"**{killed.global_name or killed.display_name}**", ) if len(self.players) <= 30 or len(self.remaining_players) <= 2 or i >= 2: start = time.time() @@ -152,7 +152,7 @@ async def start( winner = self.remaining_players[0] places.insert(0, winner) places_text = "".join( - f"**#{index}** - {player.display_name} - {kills[player]} kill{'s' if kills[player] > 1 else ''}\n" + f"**#{index}** - {player.global_name or player.display_name} - {kills[player]} kill{'s' if kills[player] > 1 else ''}\n" for index, player in enumerate(places[:10], start=1) ) places_text = list(pagify(places_text, page_length=2000))[0] diff --git a/battleroyale/views.py b/battleroyale/views.py index fa914fa0..70647e69 100644 --- a/battleroyale/views.py +++ b/battleroyale/views.py @@ -123,7 +123,10 @@ async def _callback( self: RemainingPlayerButton, interaction: discord.Interaction[Red] ) -> None: remaining_player_str = humanize_list( - [m.display_name for m in sorted(self.view.remaining, key=lambda m: m.display_name)] + [ + m.global_name or m.display_name + for m in sorted(self.view.remaining, key=lambda m: m.global_name or m.display_name) + ] ) remaining_players_str = ( f"{remaining_player_str[:4000]}..."