Files
discord_bot/lib/CogsPrepare.py
2022-08-21 22:24:52 +03:00

31 lines
711 B
Python

from os import listdir
"""
Loads, unloads Cogs files
"""
def cog_list():
cogs_list = []
for _filename in listdir('./cogs'):
if _filename.endswith('.py'):
cogs_list.append(_filename[:-3])
return cogs_list
async def cogs_dict():
cog_dict = {}
for _cog in cog_list():
cog_dict.update({f'{_cog}': f'{_cog}'})
return cog_dict
async def work_with_cogs(what_do, bot):
for _filename in cog_list():
if what_do == "load":
bot.load_extension(f'cogs.{_filename}')
elif what_do == 'unload':
bot.unload_extension(f'cogs.{_filename}')
elif what_do == 'reload':
bot.reload_extension(f'cogs.{_filename}')