From 251ac2cf47d95fa5bfee31dc29716d77998308b2 Mon Sep 17 00:00:00 2001 From: alwayscompiling Date: Tue, 2 Aug 2022 16:41:46 -0400 Subject: [PATCH] Update highscores.py to use new data classes. --- data/highscores_data.py | 9 +++++++++ highscores.py | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/data/highscores_data.py b/data/highscores_data.py index 0344dea..8142239 100644 --- a/data/highscores_data.py +++ b/data/highscores_data.py @@ -38,6 +38,15 @@ class HighscoresData: data[guild_id] = guild_obj.to_dict() return "Highscores Data\n" + json.dumps(data, indent=4) + @property + def guilds(self) -> "list[Guild]": + """ + Getter for Guilds list. + + Returns: + list[Guild]: List of Guilds tracked by Highscores Bot + """ + def add_guild(self, guild_id: int) -> None: """ Creates a new Guild and adds to Guild map. diff --git a/highscores.py b/highscores.py index 2571e10..b1dc39b 100644 --- a/highscores.py +++ b/highscores.py @@ -22,10 +22,10 @@ logger.addHandler(handler) highscores_data: HighscoresData = HighscoresData() highscores_message_map = {} -for guild in highscores_data.get_guilds(): - highscores_message_map[guild] = {} - for table in highscores_data.get_table_names(guild): - message_id = highscores_data.get_table_message_id(guild, table) +for guild in highscores_data.guilds: + highscores_message_map[guild.guild_id] = {} + for table in guild.tables: + message_id = table.message_id highscores_message_map[guild][message_id] = table submission_objects: dict = {}