auto commit sql queries

This commit is contained in:
LBlend committed 2023-04-18 21:20:20 +09:00
1 parent a38251f971
commit 35f1dafc86
6 files changed
+1 -14

No files matched your search

-4
View File
@@ -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)
-4
View File
@@ -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):
-3
View File
@@ -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)
-2
View File
@@ -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(
-1
View File
@@ -31,7 +31,6 @@ class Streak(commands.Cog):
);
"""
)
self.bot.db_connection.commit()
@commands.command()
+1
View File
@@ -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']