Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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}?")


Expand Down