Skip to content

Commit

Permalink
Close sessions in set_settings when finished
Browse files Browse the repository at this point in the history
  • Loading branch information
nonchris committed Sep 5, 2021
1 parent b5c6c43 commit b30d2a5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cogs/set_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ async def get_settings(self, ctx):
prefix += f"`{elm.value}` example `{elm.value}help`\n"

session.commit() # delete all flawed entries
session.close()

emby = utils.make_embed(color=utils.blue_light, name="Server Settings",
value=f"‌\n"
Expand Down Expand Up @@ -380,6 +381,8 @@ async def update_value_or_create_entry(ctx: commands.Context, setting_name: str,
set_by=f"{ctx.author.id}"
)

session.close()

# send reply
await Settings.send_setting_added(ctx, setting_name, value_name)

Expand Down Expand Up @@ -494,6 +497,7 @@ async def set_setting(self, ctx: commands.Context, *params):
entry.internal_type = setting_type
session.add(entry)
session.commit()

await self.send_setting_updated(ctx, setting_type, set_name)
return

Expand All @@ -506,6 +510,7 @@ async def set_setting(self, ctx: commands.Context, *params):
category=channel.category_id,
set_by=ctx.author.id)

session.close()
await self.send_setting_added(ctx, setting_type, set_name)

# now handle tracked channels
Expand Down Expand Up @@ -533,7 +538,6 @@ async def set_setting(self, ctx: commands.Context, *params):

# send reply
await self.send_setting_updated(ctx, setting_type, set_name)
return

# create new entry, channel not tracked yet
else:
Expand All @@ -551,7 +555,8 @@ async def set_setting(self, ctx: commands.Context, *params):

# send reply
await self.send_setting_updated(ctx, setting_type, set_name)
return

session.close()


def setup(bot):
Expand Down

0 comments on commit b30d2a5

Please sign in to comment.