diff --git a/cogs/utils.py b/cogs/utils.py index 5cfa9c87..bd1b7a0c 100644 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -6,8 +6,7 @@ import psutil import math import openai -import framework.isobot.embedengine -import framework.isobot.currency +from framework.isobot import currency, embedengine from discord import option, ApplicationContext from discord.ext import commands from cogs.levelling import get_level, get_xp @@ -15,7 +14,7 @@ # Variables color = discord.Color.random() -currency = framework.isobot.currency.CurrencyAPI("database/currency.json", "logs/currency.log") +currency = currency.CurrencyAPI("database/currency.json", "logs/currency.log") openai.api_key = os.getenv("chatgpt_API_KEY") chatgpt_conversation = dict() @@ -54,7 +53,7 @@ async def repo(self, ctx: ApplicationContext): @option(name="footer_icon_url", description="The icon you want to show in the embed's footer (URL ONLY)", type=str, default=None) async def embedbuilder(self, ctx: ApplicationContext, title: str, description: str, image_url: str = None, thumbnail_url: str = None, color: int = None, footer_text: str = None, footer_icon_url: str = None): await ctx.respond("Embed Built!", ephemeral=True) - await ctx.channel.send(embed=framework.isobot.embedengine.embed(title, description, image=image_url, thumbnail=thumbnail_url, color=color, footer_text=footer_text, footer_img=footer_icon_url)) + await ctx.channel.send(embed=embedengine.embed(title, description, image=image_url, thumbnail=thumbnail_url, color=color, footer_text=footer_text, footer_img=footer_icon_url)) @commands.slash_command( name='whoami', diff --git a/framework/isobot/colors.py b/framework/isobot/colors.py index bb859784..3455ec47 100644 --- a/framework/isobot/colors.py +++ b/framework/isobot/colors.py @@ -1,6 +1,8 @@ """Library used for stdout colors.""" + class Colors: """Contains general stdout colors.""" + cyan = '\033[96m' red = '\033[91m' green = '\033[92m' diff --git a/framework/isobot/currency.py b/framework/isobot/currency.py index cbb6c228..2df06bb2 100644 --- a/framework/isobot/currency.py +++ b/framework/isobot/currency.py @@ -1,3 +1,5 @@ +"""The isobot module for managing the currency db""" + import json import discord import datetime diff --git a/framework/isobot/embedengine.py b/framework/isobot/embedengine.py index f4c358fa..9ddf9368 100644 --- a/framework/isobot/embedengine.py +++ b/framework/isobot/embedengine.py @@ -1,6 +1,6 @@ """The library used for designing and outputting Discord embeds.""" + import discord -from discord import Color def embed(title: str, desc: str, *, image: str = None, thumbnail: str = None, color:int=None, footer_text: str = None, footer_img: str = None): """Designs a Discord embed. @@ -10,8 +10,8 @@ def embed(title: str, desc: str, *, image: str = None, thumbnail: str = None, co - If the color is set as "rand", then it will return the embed with a random color. - If a color is not set, it will appear as Discord's blurple embed color. """ - if color == -1: color = Color.random() - elif color == None: color = Color.blurple() + if color == -1: color = discord.Color.random() + elif color == None: color = discord.Color.blurple() local_embed = discord.Embed( title=title, description=desc, diff --git a/main.py b/main.py index 54cefd2b..fb638dca 100644 --- a/main.py +++ b/main.py @@ -7,16 +7,11 @@ import discord import asyncio import api.auth -import utils.logger -import utils.ping -from framework import * +from utils import logger, ping from math import floor from random import randint -import framework.isobot.currency -import framework.isobot.colors -import framework.isobank.authorize -import framework.isobank.manager -import framework.isobot.embedengine +from framework.isobot import currency, colors, embedengine +from framework.isobank import authorize, manager from discord import ApplicationContext, option from discord.ext import commands from discord.ext.commands import * @@ -51,18 +46,18 @@ def save(): os.mkdir('logs') try: open('logs/info-log.txt', 'x', encoding="utf-8") - utils.logger.info("Created info log", nolog=True) + logger.info("Created info log", nolog=True) time.sleep(0.5) open('logs/error-log.txt', 'x', encoding="utf-8") - utils.logger.info("Created error log", nolog=True) + logger.info("Created error log", nolog=True) time.sleep(0.5) open('logs/currency.log', 'x', encoding="utf-8") - utils.logger.info("Created currency log", nolog=True) - except Exception as e: utils.logger.error(f"Failed to make log file: {e}", nolog=True) + logger.info("Created currency log", nolog=True) + except Exception as e: logger.error(f"Failed to make log file: {e}", nolog=True) #Framework Module Loader -colors = framework.isobot.colors.Colors() -currency = framework.isobot.currency.CurrencyAPI("database/currency.json", "logs/currency.log") +colors = colors.Colors() +currency = currency.CurrencyAPI("database/currency.json", "logs/currency.log") # Theme Loader themes = False # True: enables themes; False: disables themes; @@ -92,7 +87,7 @@ async def on_ready(): await client.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name="GitHub"), status=discord.Status.idle) print(f'[main/Log] {colors.green}Status set to IDLE. Rich presence set.{colors.end}') print("[main/Flask] Starting pinger service...") - utils.ping.host() + ping.host() time.sleep(5) @client.event