Added try/except back in

pull/8/head
sgoudham 4 years ago
parent eb6eb5d7b8
commit 932cd9fb74

@ -5,7 +5,7 @@ from typing import Optional
import aiomysql import aiomysql
import discord import discord
from decouple import config from decouple import config
from discord import Embed from discord import Embed, HTTPException
from discord.ext import commands, tasks from discord.ext import commands, tasks
from discord.ext.commands import when_mentioned_or, is_owner, guild_only, has_permissions from discord.ext.commands import when_mentioned_or, is_owner, guild_only, has_permissions
@ -327,14 +327,17 @@ async def on_member_join(member):
result = await cur.fetchone() result = await cur.fetchone()
role_ids = result[5] role_ids = result[5]
if role_ids is not None: try:
# Get all the roles of the user before they were muted from the database if role_ids is not None:
roles = [member.guild.get_role(int(id_)) for id_ in role_ids.split(", ") if len(id_)] # Get all the roles of the user before they were muted from the database
# Give the member their roles back roles = [member.guild.get_role(int(id_)) for id_ in role_ids.split(", ") if len(id_)]
await member.edit(roles=roles) # Give the member their roles back
print(f"Member {member} Had Their Roles Given Back In {member.guild.name}") await member.edit(roles=roles)
else: print(f"Member {member} Had Their Roles Given Back In {member.guild.name}")
pass else:
pass
except HTTPException:
print(f"Roles Could Not Be Added To {member} in {member.guild.name}")
# Reset the roles entry for the database # Reset the roles entry for the database
update_query = """UPDATE members SET roles = NULL WHERE guildID = (%s) AND discordID = (%s)""" update_query = """UPDATE members SET roles = NULL WHERE guildID = (%s) AND discordID = (%s)"""

Loading…
Cancel
Save