From 080356fe9c9531d9cee528de3dda05a983694723 Mon Sep 17 00:00:00 2001 From: alwayscompiling Date: Sat, 13 Aug 2022 19:48:29 -0400 Subject: [PATCH] Create Guild.update_username(). --- classes/guild.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/classes/guild.py b/classes/guild.py index 30c1177..da7ad63 100644 --- a/classes/guild.py +++ b/classes/guild.py @@ -209,3 +209,23 @@ class Guild: str: string of json representation of Guild """ return json.dumps(self.to_dict(), indent=4) + + def update_username(self, old_username: str, new_username: str) -> "list[Table]": + """ + Collects list of tables that had a username updated. Sends old and new username + to the table function to update username. + + Args: + old_username (str): Username to replace. Sent to table function + new_username (str): Username to replace with. Sent to table function + + Returns: + list[Table]: All the tables that had a username updated + """ + updated_tables: "list[Table]" = [] + + for table in self.tables: + if table.update_username(old_username, new_username): + updated_tables.append(table) + + return updated_tables