Fixing error in modules import when bot runned out of the root

This commit is contained in:
Rafael Vargas
2022-07-31 19:03:41 -04:00
parent a9cfaf62a4
commit 5b61947904
4 changed files with 29 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
import os
from random import choices
import string
from discord.bot import Bot
@@ -35,13 +36,12 @@ class VulkanInitializer:
def __add_cogs(self, bot: Bot) -> None:
try:
cogsStatus = []
for filename in listdir(f'./{self.__config.COMMANDS_PATH}'):
for filename in listdir(self.__config.COMMANDS_PATH):
if filename.endswith('.py'):
cogPath = f'{self.__config.COMMANDS_PATH}.{filename[:-3]}'
cogPath = f'{self.__config.COMMANDS_FOLDER_NAME}.{filename[:-3]}'
cogsStatus.append(bot.load_extension(cogPath, store=True))
if len(bot.cogs.keys()) != self.__getTotalCogs():
print(cogsStatus)
raise VulkanError(message='Failed to load some Cog')
except VulkanError as e:
@@ -49,7 +49,7 @@ class VulkanInitializer:
def __getTotalCogs(self) -> int:
quant = 0
for filename in listdir(f'./{self.__config.COMMANDS_PATH}'):
for filename in listdir(self.__config.COMMANDS_PATH):
if filename.endswith('.py'):
quant += 1
return quant