From fbf588a85e3ae9347f17d59675df385a82dc12ea Mon Sep 17 00:00:00 2001 From: c0de Date: Thu, 10 Nov 2022 21:46:18 -0600 Subject: [PATCH] Show table of points --- GhostBallBot/game/game.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/GhostBallBot/game/game.py b/GhostBallBot/game/game.py index c1edeca..caef9c5 100644 --- a/GhostBallBot/game/game.py +++ b/GhostBallBot/game/game.py @@ -234,15 +234,28 @@ class GameManager: Points command - returns a table ordered from highest to lowest of the players and their points """ - # TODO - # value = self.message.content.split() - # try: - # if len(value) > 1: - # timestamp = dateparser.parse(value[1]) - # except: - # return await self.message.channel.send("Invalid timestamp. Try again") + message = ( + "Players, who played recently, with their points highest to lowest\n\n" + ) + message += "Player | Total Points | Last Played\n" - return await self.message.channel.send("Sorry, not implemented yet") + players = Player.select( + Player.player_name, Player.total_points, Player.last_update + ).order_by(Player.last_update.desc(), Player.total_points.desc()) + + for player in players: + message += ( + " | ".join( + [ + player.player_name, + str(player.total_points), + str(player.last_update)[:-10], + ] + ) + + "\n" + ) + + return await self.message.channel.send(message) async def help(self): """help command"""