Made sure insufficient permissions aren't always being thrown

pull/8/head
sgoudham 4 years ago
parent 5b855ff552
commit 0ca820abe7

@ -325,17 +325,24 @@ async def on_member_join(member):
result = await cur.fetchone() result = await cur.fetchone()
role_ids = result[5] role_ids = result[5]
try: # Get Enso Chan
bot = guild.get_member(client.user.id)
# Check permissions of Enso
if bot.guild_permissions.manage_roles:
if role_ids is not None: if role_ids is not None:
# Get all the roles of the user before they were muted from the database # 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_)] roles = [member.guild.get_role(int(id_)) for id_ in role_ids.split(", ") if len(id_)]
# Give the member their roles back # Give the member their roles back
await member.edit(roles=roles) await member.edit(roles=roles)
print(f"{member} Had Their Roles Given Back In {member.guild.name}") print(f"{member} Had Their Roles Given Back In {member.guild.name}")
else: else:
pass pass
except HTTPException: else:
print(f"Roles Could Not Be Added To {member} in {member.guild.name}") print(f"Insufficient Permissions to Add Roles 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)"""
@ -347,9 +354,7 @@ async def on_member_join(member):
print(cur.rowcount, f"Roles Cleared For {member} in {member.guild.name}") print(cur.rowcount, f"Roles Cleared For {member} in {member.guild.name}")
# Make sure the guild is Enso # Make sure the guild is Enso
if guild.id != enso_guild_ID: if guild.id == enso_guild_ID:
return
# Set the channel id to "newpeople" # Set the channel id to "newpeople"
new_people = guild.get_channel(enso_newpeople_ID) new_people = guild.get_channel(enso_newpeople_ID)

Loading…
Cancel
Save