Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ api/auth.py
database/currency.json
database/item.json
database/warnings.json
*.pyc
1 change: 0 additions & 1 deletion framework/e

This file was deleted.

7 changes: 7 additions & 0 deletions framework/isobot/colors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Library used for stdout colors."""
class Colors():
"""Contains general stdout colors."""
cyan = '\033[96m'
red = '\033[91m'
green = '\033[92m'
end = '\033[0m'
51 changes: 51 additions & 0 deletions framework/isobot/currency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import json
import discord

class Colors():
"""Contains general stdout colors."""
cyan = '\033[96m'
red = '\033[91m'
green = '\033[92m'
end = '\033[0m'

class CurrencyAPI(Colors):
"""The isobot API used for managing currency.

Valid commands:
- add(user, amount)
- remove(user, amount)
- reset(user)
- deposit(user, amount)
- withdraw(user, amount)"""
def __init__(self, db_path:str):
self.db_path = db_path
print(f"[Framework/Loader] {Colors.green}CurrencyAPI initialized.{Colors.end}")
def save(self):
"""Saves databases cached on memory."""
with open(self.db_path, 'w+') as f: json.dump(currency, f, indent=4)
def add(self, user:discord.User, amount:int):
"""Adds balance to the specified user."""
currency["wallet"][str(user.id)] += amount
self.save()
def remove(self, user:discord.User, amount:int):
"""Removes balance from the specified user."""
currency["wallet"][str(user.id)] -= amount
self.save()
def reset(self, user:discord.User):
"""Resets the specified user's balance."""
currency["wallet"][str(user.id)] = 0
currency["bank"][str(user.id)] = 0
self.save()
print(f"[Framework/CurrencyAPI] Currency data for \"{user.id}\" has been wiped.")
def deposit(self, user:discord.User, amount:int):
"""Moves a specified amount of coins to the user's bank."""
currency["bank"][str(user.id)] += amount
currency["wallet"][str(user.id)] -= amount
save()
print(f"[Framework/CurrencyAPI] Moved {amount} coins to bank. User: {user} [{user.id}]")
def withdraw(self, user:discord.User, amount:int):
"""Moves a specified amount of coins to the user's wallet."""
currency["wallet"][str(user.id)] += amount
currency["bank"][str(user.id)] -= amount
save()
print(f"[Framework/CurrencyAPI] Moved {amount} coins to wallet. User: {user} [{user.id}]")
39 changes: 39 additions & 0 deletions framework/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import time
import datetime
from isobot.colors import Colors

class Logger(Colors):
"""The library used for logging information.

Valid commands:
- info(text)
- warn(text)
- error(text)"""
def __init__(self, log_path:str, error_path:str):
self.log_path = log_path
self.error_path = error_path
print(f"[Framework/Loader] {Colors.green}Logger initialized.{Colors.end}")
def info(self, text:str, *, nolog=False):
current_time = datetime.datetime.now().strftime("%H:%M:%S")
print(f'[{current_time}/INFO] {text}')
if nolog == True: pass
else:
with open(self.log_path, 'a') as f:
f.write(f'[{current_time}/INFO] {text}\n')
f.close()
def warn(self, text:str, *, nolog=False):
current_time = datetime.datetime.now().strftime("%H:%M:%S")
print(f'[{current_time}/WARN] {text}')
if nolog == True: pass
else:
with open(self.log_path, 'a') as f:
f.write(f'[{current_time}/WARN] {text}\n')
f.close()
def error(self, text:str, *, nolog=False):
current_time = datetime.datetime.now().strftime("%H:%M:%S")
print(f'{Colours.red}[{current_time}/ERROR] {text}{Colours.end}')
if nolog == True: pass
else:
with open(self.error_path, 'a') as f:
f.write(f'[{current_time}/ERROR] {text}\n')
f.close()
30 changes: 3 additions & 27 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_choice, create_option
import api.auth, utils.logger, utils.ping
from framework import *
import framework.isobot.currency

# Slash option types:
# sub command: 1
Expand Down Expand Up @@ -77,33 +79,7 @@ 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)
currency_unused = framework.isobot.currency.CurrencyAPI(f'{wdir}/database/currency.json') # Initialize part of the framework (Currency)

#Events
@client.event
Expand Down