Not manually closing connections anymore

pull/9/head
sgoudham 4 years ago
parent f4e65bbbd4
commit 28a2068f9e

@ -154,9 +154,6 @@ class Bot(commands.Bot):
except asyncpg.PostgresError as e: except asyncpg.PostgresError as e:
print("PostGres Error: Starboard Records Could Not Be Loaded Into Cache On Startup", e) print("PostGres Error: Starboard Records Could Not Be Loaded Into Cache On Startup", e)
# Release connection back to pool
await pool.release(conn)
# Establish Database Connection # Establish Database Connection
self.loop.run_until_complete(create_connection()) self.loop.run_until_complete(create_connection())
# Load Information Into Cache # Load Information Into Cache
@ -623,9 +620,6 @@ class Bot(commands.Bot):
else: else:
print(rowcount, f"Record(s) inserted successfully into Members from {guild}") print(rowcount, f"Record(s) inserted successfully into Members from {guild}")
# Release connection back to pool
await pool.release(conn)
async def on_guild_remove(self, guild): async def on_guild_remove(self, guild):
""" """
Remove users in the database for the guild Remove users in the database for the guild
@ -683,9 +677,6 @@ class Bot(commands.Bot):
self.delete_starboard(guild.id) self.delete_starboard(guild.id)
self.delete_starboard_messages(guild.id) self.delete_starboard_messages(guild.id)
# Release connection back to pool
await pool.release(conn)
async def on_member_join(self, member): async def on_member_join(self, member):
""" """
Bot event to insert new members into the database Bot event to insert new members into the database
@ -773,9 +764,6 @@ class Bot(commands.Bot):
else: else:
print(rowcount, f"Roles Cleared For {member} in {member.guild}") print(rowcount, f"Roles Cleared For {member} in {member.guild}")
# Release connection back to pool
await pool.release(conn)
# 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:
new_people = guild.get_channel(self.enso_newpeople_ID) new_people = guild.get_channel(self.enso_newpeople_ID)
@ -888,12 +876,8 @@ class Bot(commands.Bot):
# Delete all information about the starboard and any messages stored # Delete all information about the starboard and any messages stored
else: else:
print(rowcount, f"Starboard deleted successfully from Guild {channel.guild}") print(rowcount, f"Starboard deleted successfully from Guild {channel.guild}")
if self.get_starboard_channel(channel.guild.id): self.delete_starboard(channel.guild.id)
self.delete_starboard(channel.guild.id) self.delete_starboard_messages(channel.guild.id)
self.delete_starboard_messages(channel.guild.id)
# Release connection back to pool
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 or channel.id == modmail_logging_channel: if channel.id == modmail_channel or channel.id == modmail_logging_channel:

Loading…
Cancel
Save