From 21865bafc432e10d7fb3a28e6489722bade85758 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Tue, 4 Aug 2020 00:18:32 +0100 Subject: [PATCH] Added try/except for role additions --- main.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index fcff17a9..4883067a 100644 --- a/main.py +++ b/main.py @@ -326,14 +326,17 @@ async def on_member_join(member): result = await cur.fetchone() role_ids = result[5] - if role_ids is not None: - # Get all the roles of the user before they were muted from the database - roles = [member.guild.get_role(int(id_)) for id_ in role_ids.split(", ") if len(id_)] - # Give the member their roles back - await member.edit(roles=roles) - print(f"Member {member} Had Their Roles Given Back In {member.guild.name}") - else: - pass + try: + if role_ids is not None: + # Get all the roles of the user before they were muted from the database + roles = [member.guild.get_role(int(id_)) for id_ in role_ids.split(", ") if len(id_)] + # Give the member their roles back + await member.edit(roles=roles) + print(f"Member {member} Had Their Roles Given Back In {member.guild.name}") + else: + pass + except Exception: + print(f"Roles Could Not Be Added To {member} in {member.guild}") # Reset the roles entry for the database update_query = """UPDATE members SET roles = NULL WHERE guildID = (%s) AND discordID = (%s)"""