Get table names from data. Update post scores to use HighscoresData class.

This commit is contained in:
alwayscompiling
2022-07-28 10:17:46 -04:00
parent 0911ebfa45
commit f497928054
2 changed files with 22 additions and 14 deletions
+17 -1
View File
@@ -112,7 +112,7 @@ class HighscoresData:
@param table: table to get category data from
@returns: list of tuples containing all category and relative score data.
"""
return self._data[str(guild_id)][table]["categories"].items()
return self._data[str(guild_id)]["tables"][table]["categories"].items()
def get_config_highscore_size(self) -> int:
"""
@@ -149,6 +149,22 @@ class HighscoresData:
"""
return self._data[str(guild_id)]["tables"][table]["message_id"]
def get_table_names(self, guild_id) -> "list[str]":
"""
Returns a list of table names.
@param guild_id: guild id to retrieve from.
@returns: list of table names
"""
tables: "list[str]" = []
for table, data in self._data[str(guild_id)][ # pylint: disable=unused-variable
"tables"
].items():
tables.append(table)
return tables
def remove_guild(self, guild_id: int, guild_name: str) -> None:
"""
Removes a guild's data from object. Saves backup.