Updated guild listener to HighscoresData class.

This commit is contained in:
alwayscompiling
2022-07-27 22:32:28 -04:00
parent beedf946c9
commit 0911ebfa45
2 changed files with 18 additions and 12 deletions
+16
View File
@@ -149,6 +149,22 @@ class HighscoresData:
"""
return self._data[str(guild_id)]["tables"][table]["message_id"]
def remove_guild(self, guild_id: int, guild_name: str) -> None:
"""
Removes a guild's data from object. Saves backup.
@param guild_id: guild id to remove.
@param guild_name: name of guild for backup.
"""
old_data = self._data.pop(str(guild_id))
save_highscores_data(self._data)
if not os.path.exists("deleted_backups"):
os.mkdir("deleted_backups")
with open(f"deleted_backups/{guild_name}_backup.json", encoding="utf-8", mode="w") as file:
file.write(json.dumps(old_data, indent=4))
def reset_guild_data(self, guild_id: int) -> None:
"""
Resets highscore data for a guild. Should only be used for development really...