26 lines
612 B
Python
26 lines
612 B
Python
from os import listdir
|
|
|
|
"""
|
|
Loads, unloads Cogs files
|
|
cog_list: return list of cog filenames
|
|
|
|
"""
|
|
|
|
|
|
def cog_list():
|
|
cogs_list = []
|
|
for _filename in listdir('./cogs'):
|
|
if _filename.endswith('.py'):
|
|
cogs_list.append(_filename[:-3])
|
|
return cogs_list
|
|
|
|
|
|
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}')
|