|
|
@ -236,10 +236,8 @@ class Bot(commands.Bot):
|
|
|
|
|
|
|
|
|
|
|
|
def get_roles_persist(self, guild_id):
|
|
|
|
def get_roles_persist(self, guild_id):
|
|
|
|
"""Returning rolespersist value of the guild"""
|
|
|
|
"""Returning rolespersist value of the guild"""
|
|
|
|
try:
|
|
|
|
|
|
|
|
return self.enso_cache[guild_id]["roles_persist"]
|
|
|
|
return self.enso_cache.get(guild_id).get("roles_persist")
|
|
|
|
except KeyError:
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def update_role_persist(self, guild_id, value):
|
|
|
|
async def update_role_persist(self, guild_id, value):
|
|
|
|
"""Update the rolepersist value of the guild (Enabled or Disabled)"""
|
|
|
|
"""Update the rolepersist value of the guild (Enabled or Disabled)"""
|
|
|
@ -310,10 +308,8 @@ class Bot(commands.Bot):
|
|
|
|
|
|
|
|
|
|
|
|
def get_modlog_for_guild(self, guild_id):
|
|
|
|
def get_modlog_for_guild(self, guild_id):
|
|
|
|
"""Get the modlog channel of the guild that the user is in"""
|
|
|
|
"""Get the modlog channel of the guild that the user is in"""
|
|
|
|
try:
|
|
|
|
|
|
|
|
return self.enso_cache[guild_id]["modlogs"]
|
|
|
|
return self.enso_cache.get(guild_id).get("modlogs")
|
|
|
|
except KeyError:
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# --------------------------------------------!End ModLogs Section!-------------------------------------------------
|
|
|
|
# --------------------------------------------!End ModLogs Section!-------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
@ -558,7 +554,9 @@ class Bot(commands.Bot):
|
|
|
|
|
|
|
|
|
|
|
|
# Catch errors
|
|
|
|
# Catch errors
|
|
|
|
except asyncpg.PostgresError as e:
|
|
|
|
except asyncpg.PostgresError as e:
|
|
|
|
print(f"PostGres Error: Member {member.id} was not be able to be added to Guild {member.guild.id}", e)
|
|
|
|
print(
|
|
|
|
|
|
|
|
f"PostGres Error: {member} | {member.id} was not be able to be added to {member.guild} | {member.guild.id}",
|
|
|
|
|
|
|
|
e)
|
|
|
|
|
|
|
|
|
|
|
|
# Print success
|
|
|
|
# Print success
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -574,7 +572,7 @@ class Bot(commands.Bot):
|
|
|
|
|
|
|
|
|
|
|
|
# Catch errors
|
|
|
|
# Catch errors
|
|
|
|
except asyncpg.PostgresError as e:
|
|
|
|
except asyncpg.PostgresError as e:
|
|
|
|
print(f"PostGres Error: Member {member} Record Not Found", e)
|
|
|
|
print(f"PostGres Error: {member} | {member.id} Record Not Found", e)
|
|
|
|
|
|
|
|
|
|
|
|
# Give roles back to the user if role persist is enabled
|
|
|
|
# Give roles back to the user if role persist is enabled
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -595,11 +593,12 @@ class Bot(commands.Bot):
|
|
|
|
|
|
|
|
|
|
|
|
# Don't give roles if user has no roles to be given
|
|
|
|
# Don't give roles if user has no roles to be given
|
|
|
|
elif bot.guild_permissions.manage_roles and not flag:
|
|
|
|
elif bot.guild_permissions.manage_roles and not flag:
|
|
|
|
print(f"Member {member.id} Had No Roles To Be Given")
|
|
|
|
print(f"Member {member} | {member.id} Had No Roles To Be Given")
|
|
|
|
|
|
|
|
|
|
|
|
# No permissions to give roles in the server
|
|
|
|
# No permissions to give roles in the server
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print(f"Insufficient Permissions to Add Roles to Member {member.id} in Guild {member.guild.id}")
|
|
|
|
print(
|
|
|
|
|
|
|
|
f"Insufficient Permissions to Add Roles to {member} | {member.id} in {member.guild} | {member.guild.id}")
|
|
|
|
|
|
|
|
|
|
|
|
# Make sure the guild is Enso and send welcoming embed to the server
|
|
|
|
# Make sure the guild is Enso and send welcoming embed to the server
|
|
|
|
if guild.id == self.enso_guild_ID:
|
|
|
|
if guild.id == self.enso_guild_ID:
|
|
|
@ -670,14 +669,13 @@ class Bot(commands.Bot):
|
|
|
|
# Get the modlogs channel (channel or none)
|
|
|
|
# Get the modlogs channel (channel or none)
|
|
|
|
modlogs = self.get_modlog_for_guild(channel.guild.id)
|
|
|
|
modlogs = self.get_modlog_for_guild(channel.guild.id)
|
|
|
|
|
|
|
|
|
|
|
|
# Stupid dumb error handling that I shouldn't have to do
|
|
|
|
# Get the modmail record - (normal and logging channels)
|
|
|
|
try:
|
|
|
|
modmail_channel = self.get_modmail(channel.guild.id).get("modmail_channel_id")
|
|
|
|
modmail_channel = self.modmail_cache[channel.guild.id]["modmail_channel_id"]
|
|
|
|
modmail_logging_channel = self.get_modmail(channel.guild.id).get("modmail_logging_channel_id")
|
|
|
|
except KeyError:
|
|
|
|
|
|
|
|
modmail_channel = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get pool
|
|
|
|
# Get pool
|
|
|
|
pool = self.db
|
|
|
|
pool = self.db
|
|
|
|
|
|
|
|
|
|
|
|
# Delete the modlogs system from the database when modlogs channel is deleted
|
|
|
|
# Delete the modlogs system from the database when modlogs channel is deleted
|
|
|
|
if channel.id == modlogs:
|
|
|
|
if channel.id == modlogs:
|
|
|
|
# Setup pool connection
|
|
|
|
# Setup pool connection
|
|
|
@ -701,7 +699,7 @@ class Bot(commands.Bot):
|
|
|
|
await pool.release(conn)
|
|
|
|
await pool.release(conn)
|
|
|
|
|
|
|
|
|
|
|
|
# If modmail channels are deleted, delete the entire system
|
|
|
|
# If modmail channels are deleted, delete the entire system
|
|
|
|
if channel.id == modmail_channel:
|
|
|
|
if channel.id == modmail_channel or channel.id == modmail_logging_channel:
|
|
|
|
# Set up pool connection
|
|
|
|
# Set up pool connection
|
|
|
|
async with pool.acquire() as conn:
|
|
|
|
async with pool.acquire() as conn:
|
|
|
|
|
|
|
|
|
|
|
|