fixed start after move
This commit is contained in:
@@ -15,6 +15,15 @@ from .Logger import logger
|
||||
|
||||
|
||||
def cog_list(fold: str = './cogs') -> List[str]:
|
||||
"""
|
||||
A function that generates a list of cog names based on the files present in a specified folder.
|
||||
|
||||
Parameters:
|
||||
- fold (str): The directory path where the cog files are located. Defaults to './cogs'.
|
||||
|
||||
Returns:
|
||||
- List[str]: A list of cog names without the '.py' extension.
|
||||
"""
|
||||
cogs_list = []
|
||||
for _filename in listdir(fold):
|
||||
if _filename.endswith('.py'):
|
||||
@@ -25,6 +34,22 @@ def cog_list(fold: str = './cogs') -> List[str]:
|
||||
def work_with_cogs(what_do: str,
|
||||
bot: InteractionBotBase,
|
||||
cog: str | list):
|
||||
"""
|
||||
Perform the specified action on the given cog or list of cogs.
|
||||
Args:
|
||||
what_do (str): The action to perform (load, unload, reload, disable, enable).
|
||||
bot (InteractionBotBase): The bot instance to work with.
|
||||
cog (str | list): The name of the cog or a list of cogs to work with.
|
||||
Raises:
|
||||
ValueError: If the action is not recognized.
|
||||
Returns:
|
||||
None
|
||||
--------
|
||||
:param cog: str | list
|
||||
:param bot: InteractionBotBase
|
||||
:param what_do: str = ['load', 'unload', 'reload', 'disable', 'enable']
|
||||
"""
|
||||
|
||||
if isinstance(cog, str):
|
||||
cog = cog.split()
|
||||
for _filename in cog:
|
||||
@@ -49,3 +74,5 @@ def work_with_cogs(what_do: str,
|
||||
f'cogs/{_filename}.py')
|
||||
bot.load_extension(f'cogs.{_filename}')
|
||||
logger.info(f'Cog {_filename} started and enabled')
|
||||
else:
|
||||
raise ValueError(f"Unrecognized action: {what_do}")
|
||||
|
||||
Reference in New Issue
Block a user