diff --git a/main.py b/main.py index 691acc6f..360119d6 100644 --- a/main.py +++ b/main.py @@ -77,6 +77,34 @@ class plugins: levelling:bool = False music:bool = False +class CurrencyAPI(colors): + """The isobot API used for managing currency. + + Valid commands: + - add(user, amount) + - remove(user, amount) + - reset(user)""" + + def __init__(self, db_path:str): + self.db_path = db_path + print(f"[Framework/Loader] {colors.green}CurrencyAPI initialized.{colors.end}") + def add(user:discord.User, amount:int): + """Adds balance to the specified user.""" + currency["wallet"][str(user.id)] += amount + save() + def remove(user:discord.User, amount:int): + """Removes balance from the specified user.""" + currency["wallet"][str(user.id)] -= amount + save() + def reset(user:discord.User): + """Resets the specified user's balance.""" + currency["wallet"][str(user.id)] = 0 + currency["bank"][str(user.id)] = 0 + save() + print(f"[Framework/CurrencyAPI] Currency data for \"{user.id}\" has been wiped.") + +currency_unused = CurrencyAPI(f'{wdir}/database/currency.json') # Initialize part of the framework (Currency) + #Events @client.event async def on_ready(): @@ -1115,7 +1143,7 @@ async def gift(ctx:SlashContext, user:discord.User, item:str, amount:int=1): localembed.add_field(name="and you have", value=f"**{items[str(ctx.author.id)][item]} {item}**s") await ctx.reply(embed=localembed) except KeyError as e: - utils.logger.error(e) + utils.logger.error(e) await ctx.reply(f"wtf is {item}?")