From 019f68a1e8b9104ba935387dae6c2bea01bafa78 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh <102361830+SeaswimmerTheFsh@users.noreply.github.com> Date: Tue, 14 Mar 2023 19:49:55 -0400 Subject: [PATCH] added another check credit add and credit remove will now check if the new balance is below the minimum balance - on that note, added min_bal as a config option --- sugoncredit/sugoncredit.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sugoncredit/sugoncredit.py b/sugoncredit/sugoncredit.py index 4abb60b..4b79e0d 100644 --- a/sugoncredit/sugoncredit.py +++ b/sugoncredit/sugoncredit.py @@ -10,7 +10,8 @@ class SugonCredit(commands.Cog): self.config.register_global( bank_name = "Social Credit Enforcement Agency", currency_name = "Social Credit", - max_bal = 1000000000 + max_bal = 1000000000, + min_bal = -1000000000 ) con = sqlite3.connect('credit_db') cur = con.cursor() @@ -94,6 +95,7 @@ class SugonCredit(commands.Cog): bank_name = await self.config.bank_name() currency_name = await self.config.currency_name() max_bal = await self.config.max_bal() + min_bal = await self.config_min_bal() if cur.execute(f'''SELECT user_id FROM credit WHERE EXISTS (SELECT user_id FROM credit WHERE {target.id});''')=="FALSE": await self.new_user_generation(self, target) @@ -109,9 +111,12 @@ class SugonCredit(commands.Cog): output_amount = (f'{val:,}') output_new_bal = (f'{new_bal:,}') output_max_bal = (f'{max_bal:,}') + output_min_bal = (f'{min_bal:,}') if new_bal > max_bal: await ctx.send(content=f"You are attempting to set {target.mention}'s balance to above {output_max_bal}. Please try again!") return + elif new_bal < min_bal: + await ctx.send(content=f"You are attempting to set {target.mention}'s balance to below {output_min_bal}. Please try again!") elif ctx.guild.id == 204965774618656769: logging_channel = self.bot.get_channel(1082495815878189076) cur.execute(f'''UPDATE credit @@ -149,6 +154,7 @@ class SugonCredit(commands.Cog): bank_name = await self.config.bank_name() currency_name = await self.config.currency_name() max_bal = await self.config.max_bal() + min_bal = await self.config_min_bal() if cur.execute(f'''SELECT user_id FROM credit WHERE EXISTS (SELECT user_id FROM credit WHERE {target.id});''')=="FALSE": await self.new_user_generation(self, target) @@ -162,8 +168,11 @@ class SugonCredit(commands.Cog): output_amount = (f'{val:,}') output_new_bal = (f'{new_bal:,}') output_max_bal = (f'{max_bal:,}') + output_min_bal = (f'{min_bal:,}') if new_bal > max_bal: await ctx.send(content=f"You are attempting to set {target.mention}'s balance to above {output_max_bal}. Please try again!") + elif new_bal < min_bal: + await ctx.send(content=f"You are attempting to set {target.mention}'s balance to below {output_min_bal}. Please try again!") elif ctx.guild.id == 204965774618656769: cur.execute(f'''UPDATE credit SET balance = {new_bal}