diff --git a/src/cogs/birthday.py b/src/cogs/birthday.py index 0e9e712..25f9d29 100644 --- a/src/cogs/birthday.py +++ b/src/cogs/birthday.py @@ -36,7 +36,6 @@ class Birthday(commands.Cog): ); """ ) - self.bot.db_connection.commit() @tasks.loop(hours=24) async def birthday_check(self): @@ -171,11 +170,9 @@ class Birthday(commands.Cog): INSERT INTO birthdays (discord_id, birthday) VALUES (%s, %s) """, (user_id, birthday)) - self.bot.db_connection.commit() except psycopg2.errors.UniqueViolation: self.bot.db_connection.rollback() self.cursor.execute('UPDATE birthdays SET birthday = %s WHERE discord_id = %s', (birthday, user_id)) - self.bot.db_connection.commit() @app_commands.checks.bot_has_permissions(embed_links=True) @app_commands.checks.cooldown(1, 5) @@ -230,7 +227,6 @@ class Birthday(commands.Cog): """ self.cursor.execute('DELETE FROM birthdays WHERE discord_id = (%s)', (interaction.user.id,)) - self.bot.db_connection.commit() embed = embed_templates.success(interaction, text='Bursdag fjernet') await interaction.response.send_message(embed=embed) diff --git a/src/cogs/deprecated/social_credit.py b/src/cogs/deprecated/social_credit.py index 4791b08..df09d97 100644 --- a/src/cogs/deprecated/social_credit.py +++ b/src/cogs/deprecated/social_credit.py @@ -64,7 +64,6 @@ class SocialCredit(commands.Cog): ); """ ) - self.bot.db_connection.commit() def add_new_citizen(func): async def wrapper(*args, **kwargs): @@ -95,7 +94,6 @@ class SocialCredit(commands.Cog): """, (user_id, self.START_POINTS), ) - self.bot.db_connection.commit() async def get_leaderboard(self, ctx, page, worst=False): @@ -143,7 +141,6 @@ class SocialCredit(commands.Cog): """, (points, user_id), ) - self.bot.db_connection.commit() @add_new_citizen async def social_reward(self, user_id, points): @@ -156,7 +153,6 @@ class SocialCredit(commands.Cog): """, (points, user_id), ) - self.bot.db_connection.commit() @commands.command() async def credits(self, ctx, *, bruker: discord.Member = None): diff --git a/src/cogs/gullkorn.py b/src/cogs/gullkorn.py index 90acc3a..96abb8b 100644 --- a/src/cogs/gullkorn.py +++ b/src/cogs/gullkorn.py @@ -47,7 +47,6 @@ class Gullkorn(commands.Cog): ORDER BY citations_posted DESC; """ ) - self.bot.db_connection.commit() def __construct_data_string(self, data: list[tuple[int, int, int]]) -> str: """ @@ -100,8 +99,6 @@ class Gullkorn(commands.Cog): """, (message.author.id,) ) - self.bot.db_connection.commit() - gullkorn_group = app_commands.Group(name='gullkorn', description='Se statistikk for gullkorn') @app_commands.checks.bot_has_permissions(embed_links=True) diff --git a/src/cogs/mc_whitelist.py b/src/cogs/mc_whitelist.py index aa56cb5..5d099db 100644 --- a/src/cogs/mc_whitelist.py +++ b/src/cogs/mc_whitelist.py @@ -32,7 +32,6 @@ class MCWhitelist(commands.Cog): ); """ ) - self.bot.db_connection.commit() @app_commands.checks.bot_has_permissions(embed_links=True) @app_commands.checks.cooldown(1, 5) @@ -87,7 +86,6 @@ class MCWhitelist(commands.Cog): """, (interaction.user.id, data['id']), ) - self.bot.db_connection.commit() await interaction.response.send_message( embed=embed_templates.success( diff --git a/src/cogs/streak.py b/src/cogs/streak.py index e9352f6..f4c3df4 100644 --- a/src/cogs/streak.py +++ b/src/cogs/streak.py @@ -31,7 +31,6 @@ class Streak(commands.Cog): ); """ ) - self.bot.db_connection.commit() @commands.command() diff --git a/src/run.py b/src/run.py index 302c1a6..c8e2b0c 100644 --- a/src/run.py +++ b/src/run.py @@ -35,6 +35,7 @@ class Bot(commands.Bot): user=db['username'], password=db['password'], ) + self.db_connection.autocommit = True # Fetch misc config values self.mc_rcon_password = config['minecraft']['rcon_password']