added base tests

This commit is contained in:
bacon
2024-03-15 15:46:45 +03:00
parent eca1f01c16
commit 736621c516
7 changed files with 126 additions and 9 deletions

View File

@@ -7,14 +7,11 @@ work_with_cogs: loads, reloads and unloads cogs files
"""
from os import listdir, rename
from typing import List
from disnake.ext import commands
from .Logger import logger
async def cog_list(fold: str = './cogs') -> List[str]:
async def cog_list(fold: str = './cogs') -> list:
cogs_list = []
for _filename in listdir(fold):
if _filename.endswith('.py'):
@@ -22,11 +19,11 @@ async def cog_list(fold: str = './cogs') -> List[str]:
return cogs_list
async def work_with_cogs(what_do, bot: commands.Bot, cog):
async def work_with_cogs(what_do, bot, cog):
if isinstance(cog, str):
cog = cog.split()
for _filename in cog:
if what_do == "load":
if what_do == "lad":
bot.load_extension(f'cogs.{_filename}')
logger.info(f'Loaded cog {_filename}')
elif what_do == 'unload':
@@ -37,7 +34,6 @@ async def work_with_cogs(what_do, bot: commands.Bot, cog):
logger.info(f'Cog {_filename} reloaded')
elif what_do == 'disable':
bot.unload_extension(f'cogs.{_filename}')
rename(f'cogs/{_filename}.py', f'cogs/disabled/{_filename}.py')
logger.info(f'Cog {_filename} stopped and disabled')
elif what_do == 'enable':
rename(f'cogs/disabled/{_filename}.py', f'cogs/{_filename}.py')

View File

@@ -2,6 +2,8 @@
lib.Commands
~~~~~~~~~~~~~~
Some prepare for commands
"""
from json import load, decoder, dump, JSONDecodeError
from os import getenv