Finishing ErrorHandler integration

This commit is contained in:
Rafael Vargas 2021-12-24 14:19:16 -04:00
parent 3639ba3280
commit 29998997bc
2 changed files with 5 additions and 3 deletions

View File

@ -3,6 +3,7 @@ import discord
from config import config from config import config
from discord.ext import commands from discord.ext import commands
from vulkan.ErrorHandler import ErrorHandler
intents = discord.Intents.default() intents = discord.Intents.default()
@ -12,6 +13,7 @@ bot = commands.Bot(command_prefix=config.BOT_PREFIX, pm_help=True,
case_insensitive=True, intents=intents) case_insensitive=True, intents=intents)
bot.remove_command('help') bot.remove_command('help')
if __name__ == '__main__': if __name__ == '__main__':
config.ABSOLUTE_PATH = os.path.dirname(os.path.abspath(__file__)) config.ABSOLUTE_PATH = os.path.dirname(os.path.abspath(__file__))
config.COOKIE_PATH = config.ABSOLUTE_PATH + config.COOKIE_PATH config.COOKIE_PATH = config.ABSOLUTE_PATH + config.COOKIE_PATH
@ -20,11 +22,12 @@ if __name__ == '__main__':
print("Error: No bot token!") print("Error: No bot token!")
exit() exit()
bot.log_error = ErrorHandler('errors') # Creating the error handler
for extension in config.INITIAL_EXTENSIONS: for extension in config.INITIAL_EXTENSIONS:
try: try:
bot.load_extension(extension) bot.load_extension(extension)
except Exception as e: except Exception as e:
print(e) print(e)
bot.run(config.BOT_TOKEN, bot=True, reconnect=True)
bot.run(config.BOT_TOKEN, bot=True, reconnect=True)

View File

@ -22,7 +22,6 @@ class ErrorHandler():
full_path = self.__open_file() full_path = self.__open_file()
if isinstance(full_path, bool): if isinstance(full_path, bool):
print('Parei')
return False return False
error_str = self.__prepare_error(error) error_str = self.__prepare_error(error)