Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hunter87ff committed Nov 5, 2024
1 parent 7c98e67 commit b25971d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from flask import Flask
from threading import Thread
ap = Flask(__name__)
ap.config['WTF_CSRF_ENABLED'] = False # Disable CSRF protection safely
ap.config['WTF_CSRF_ENABLED'] = False
@ap.route("/")
def home():return "Status : Online"
def run():ap.run(host='0.0.0.0', port=8080)
Expand Down
2 changes: 1 addition & 1 deletion src/ext/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def info( message):
Logger._logger.info(message)

@staticmethod
def warning( message):
def warning( message, *args):
formatter = logging.Formatter(f"{Logger.colors('magenta')}[{Logger.get_time()}]{Logger.colors('WARNING')} [%(levelname)s]: {Logger.colors('none')}%(message)s")
Logger.console_handler.setFormatter(formatter)
Logger._logger.warning(message)
Expand Down
12 changes: 8 additions & 4 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@
"""


import os
import platform
import asyncio
import traceback
from modules import config
if platform.system() == "Windows": os.system("cls")
else: os.system("clear")
db = config.get_db()
from modules.bot import bot
exec(db.cfdata["runner"])
async def launch(db=db):
async def launch():
try:
await bot.start(db.token, reconnect=True)
await bot.start(bot.db.token, reconnect=True)
except Exception:
config.Logger.error(f"{traceback.format_exc()} ")
del db
asyncio.run(launch())

asyncio.run(launch())
11 changes: 11 additions & 0 deletions src/modules/checker.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
"""
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2022 [email protected]
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
"""



import asyncio
import discord
from discord.ext import commands
Expand Down
25 changes: 1 addition & 24 deletions src/modules/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from os import environ as env
import sys
from dotenv import load_dotenv
load_dotenv()

Expand Down Expand Up @@ -113,26 +112,4 @@ async def is_dev(ctx:commands.Context | discord.Interaction):
await ctx.send("Command is under development", ephemeral=True)
return False
return True

async def error_log(bot:commands.Bot, ctx:commands.Context, exception:str|list):
"""
Logs the error in the error log channel
"""
try:
erl = bot.get_channel(erl)
await logger.error(ctx.message, exception)
await erl.send(f"""
<@885193210455011369>
```py
Command : {ctx.command.name}
Guild Name: {ctx.guild}
Guild Id : {ctx.guild.id}
Channel Id : {ctx.channel.id}
User Tag : {ctx.author}
User Id : {ctx.author.id}
Traceback: {exception}
```"""
)
except Exception as e:
await logger.error(ctx.message, e)

6 changes: 3 additions & 3 deletions src/modules/message_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,6 @@ async def error_handle(ctx:commands.Context, error:errors.DiscordException, bot:
await cmdnf.send(f"```py\nGuild Name: {ctx.guild}\nGuild Id : {ctx.guild.id}\nUser Tag : {ctx.author}\nUser Id : {ctx.author.id}\nCommand : {ctx.message.content}```")
elif isinstance(error, (commands.MissingRole, commands.MissingAnyRole)):
return await ctx.send(embed=Embed(color=0xff0000, description=str(error)))
elif isinstance(error, commands.UserInputError):
return await ctx.send(embed=Embed(color=0xff0000, description="Please Enter Valid Arguments"))
elif isinstance(error, commands.EmojiNotFound):
return await ctx.send(embed=Embed(color=0xff0000, description="Emoji Not Found"))
elif isinstance(error, commands.NotOwner):
Expand Down Expand Up @@ -334,9 +332,11 @@ async def error_handle(ctx:commands.Context, error:errors.DiscordException, bot:
return await ctx.send(embed=Embed(description="Maximum number of reactions reached (20)", color=0xff0000))
elif "error code: 30013" in str(error):
return await ctx.send(embed=Embed(description="Maximum number of guild channels reached (500)", color=0xff0000))
elif isinstance(error, commands.UserInputError):
return await ctx.send(embed=Embed(color=0xff0000, description="Please Enter Valid Arguments"))
elif isinstance(error, config.discord.HTTPException):
await erl.send(f"```json\n{error.text}\nStatus Code : {error.status}\n```")
else: await erl.send(f"<@885193210455011369>\n```py\nCommand : {ctx.command.name}\nGuild Name: {ctx.guild}\nGuild Id : {ctx.guild.id}\nChannel Id : {ctx.channel.id}\nUser Tag : {ctx.author}\nUser Id : {ctx.author.id}\n\n\n{error}\nTraceback: {traceback.format_exception(error)}\n```")

except Exception as e:
await config.error_log(bot=bot, ctx=ctx, exception=traceback.format_exception(e))
await config.logger.warning(traceback.format_exception(e))

0 comments on commit b25971d

Please sign in to comment.