refractor lib code
This commit is contained in:
30
lib/CogsPrepare.py
Normal file
30
lib/CogsPrepare.py
Normal file
@@ -0,0 +1,30 @@
|
||||
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}')
|
||||
Reference in New Issue
Block a user