Update sugoncredit.py

This commit is contained in:
SeaswimmerTheFsh 2023-03-15 11:59:46 -04:00
parent 691cacbbc6
commit 2169436a70

View file

@ -15,13 +15,15 @@ class SugonCredit(commands.Cog):
max_bal = 1000000000, max_bal = 1000000000,
min_bal = -1000000000 min_bal = -1000000000
) )
con = sqlite3.connect('credit_db') data_path = data_manager.cog_data_path(self) / "credit.db"
con = sqlite3.connect(f'{data_path}')
con.commit() con.commit()
con.close() con.close()
def new_guild_generation(self, ctx): def new_guild_generation(self, ctx):
"""Adds a new table for a guild to the SQLite databse.""" """Adds a new table for a guild to the SQLite databse."""
con = sqlite3.connect('credit_db') data_path = data_manager.cog_data_path(self) / "credit.db"
con = sqlite3.connect(f'{data_path}')
cur = con.cursor() cur = con.cursor()
exist_check = cur.execute(f'''IF EXISTS exist_check = cur.execute(f'''IF EXISTS
(SELECT object_id FROM sys.tables (SELECT object_id FROM sys.tables
@ -38,7 +40,8 @@ class SugonCredit(commands.Cog):
def new_user_generation(self, ctx, target): def new_user_generation(self, ctx, target):
"""Adds a new user to the SQLite database.""" """Adds a new user to the SQLite database."""
username = str(target) username = str(target)
con = sqlite3.connect('credit_db') data_path = data_manager.cog_data_path(self) / "credit.db"
con = sqlite3.connect(f'{data_path}')
cur = con.cursor() cur = con.cursor()
cur.execute(f'''INSERT INTO {ctx.guild.id} cur.execute(f'''INSERT INTO {ctx.guild.id}
VALUES ('{username}', {target.id}, 250);''') VALUES ('{username}', {target.id}, 250);''')
@ -48,7 +51,8 @@ class SugonCredit(commands.Cog):
def username_updater(self, ctx, target): def username_updater(self, ctx, target):
"""Updates a users' username in the SQLite database.""" """Updates a users' username in the SQLite database."""
new_username = str(target) new_username = str(target)
con = sqlite3.connect('credit_db') data_path = data_manager.cog_data_path(self) / "credit.db"
con = sqlite3.connect(f'{data_path}')
cur = con.cursor() cur = con.cursor()
cur.execute(f'''UPDATE {ctx.guild.id} cur.execute(f'''UPDATE {ctx.guild.id}
SET username = '{new_username}' SET username = '{new_username}'
@ -66,7 +70,8 @@ class SugonCredit(commands.Cog):
async def leaderboard(self, ctx, page: int = 1): async def leaderboard(self, ctx, page: int = 1):
"""Shows the individuals with the highest balances.""" """Shows the individuals with the highest balances."""
await ctx.send(content="This command isn't done yet!") await ctx.send(content="This command isn't done yet!")
con = sqlite3.connect('credit_db') data_path = data_manager.cog_data_path(self) / "credit.db"
con = sqlite3.connect(f'{data_path}')
cur = con.cursor() cur = con.cursor()
await self.new_guild_generation(self, ctx) await self.new_guild_generation(self, ctx)
bank_name = await self.config.guild(ctx.guild).bank_name() bank_name = await self.config.guild(ctx.guild).bank_name()
@ -81,7 +86,8 @@ class SugonCredit(commands.Cog):
@commands.guild_only() @commands.guild_only()
async def balance(self, ctx, user: discord.Member = None): async def balance(self, ctx, user: discord.Member = None):
"""Checks an account's balance.""" """Checks an account's balance."""
con = sqlite3.connect('credit_db') data_path = data_manager.cog_data_path(self) / "credit.db"
con = sqlite3.connect(f'{data_path}')
cur = con.cursor() cur = con.cursor()
await self.new_guild_generation(self, ctx) await self.new_guild_generation(self, ctx)
bank_name = await self.config.guild(ctx.guild).bank_name() bank_name = await self.config.guild(ctx.guild).bank_name()
@ -116,7 +122,8 @@ class SugonCredit(commands.Cog):
except ValueError: except ValueError:
await ctx.send(content="``amount`` must be a number! Please try again.") await ctx.send(content="``amount`` must be a number! Please try again.")
return return
con = sqlite3.connect('credit_db') data_path = data_manager.cog_data_path(self) / "credit.db"
con = sqlite3.connect(f'{data_path}')
cur = con.cursor() cur = con.cursor()
await self.new_guild_generation(self, ctx) await self.new_guild_generation(self, ctx)
image = discord.File(fp=data_manager.bundled_data_path(self) / "add.png", filename="Add.png") image = discord.File(fp=data_manager.bundled_data_path(self) / "add.png", filename="Add.png")
@ -177,7 +184,8 @@ class SugonCredit(commands.Cog):
await ctx.send(content="``amount`` must be a number. Please try again!") await ctx.send(content="``amount`` must be a number. Please try again!")
return return
image = discord.File(fp=data_manager.bundled_data_path(self) / "remove.mp4", filename="MEGA_BASE.mp4") image = discord.File(fp=data_manager.bundled_data_path(self) / "remove.mp4", filename="MEGA_BASE.mp4")
con = sqlite3.connect('credit_db') data_path = data_manager.cog_data_path(self) / "credit.db"
con = sqlite3.connect(f'{data_path}')
cur = con.cursor() cur = con.cursor()
await self.new_guild_generation(self, ctx) await self.new_guild_generation(self, ctx)
bank_name = await self.config.bank_name() bank_name = await self.config.bank_name()