Finished Config command group

This commit is contained in:
2021-07-18 23:16:58 +01:00
parent b6203566b3
commit e62342bc9a
12 changed files with 508 additions and 166 deletions

View File

@@ -91,8 +91,8 @@ def setConfig(guild:discord.Guild):
cDict['mod'] = guild.system_channel.id
if 'configured' not in gDict or type(gDict['configured']) is not bool:
gDict['configured'] = False
if 'membership' not in gDict or type(gDict['membership']) is not dict or None in gDict['membership']:
gDict['membership'] = {}
if 'membership' not in gDict or type(gDict['membership']) is not list or None in gDict['membership']:
gDict['membership'] = []
if 'name' not in gDict or gDict['name'] != guild.name:
gDict['name'] = guild.name
if 'owner' not in gDict or gDict['owner'] != guild.owner_id:
@@ -169,7 +169,7 @@ def checkConfig(guild:discord.Guild):
return conf[guildStr]['configured'], output
def parseConfigCheck(missingKeys: list):
output = 'Configuration values for the following have not been defined:\n\n'
output = 'Configuration values for the following mandatory parameters have not been defined:\n\n'
for entry in missingKeys:
if '.' in entry:
e1, e2 = entry.split('.')
@@ -217,23 +217,40 @@ def unloadCog(filepath:str):
path[-1] = path[-1][:-3]
client.unload_extension('.'.join(path))
def loadCogs(cogClass:str = 'all'):
def reloadCog(filepath:str):
path = os.path.normpath(filepath).split(os.path.sep)
if path[-1].endswith('.py'):
path[-1] = path[-1][:-3]
client.reload_extension('.'.join(path))
def loadCogs(cogClass:str = '--all'):
for category in os.listdir(f'./{cogsDir}'):
if cogClass == 'all' or cogClass == category:
if cogClass == '--all' or cogClass == category:
for cogfile in os.listdir(f'./{cogsDir}/{category}'):
if cogfile.endswith('.py'):
loadCog(f'./{cogsDir}/{category}/{cogfile}')
def unloadCogs(cogClass:str = 'all'):
def unloadCogs(cogClass:str = '--all'):
for category in os.listdir(f'./{cogsDir}'):
if cogClass == 'all' or cogClass == category:
if cogClass == '--all' or cogClass == category:
for cogfile in os.listdir(f'./{cogsDir}/{category}'):
if cogfile.endswith('.py'):
unloadCog(f'./{cogsDir}/{category}/{cogfile}')
loadCogs('devcommands')
def reloadCogs(cogClass:str = '--all'):
for category in os.listdir(f'./{cogsDir}'):
if cogClass == '--all' or cogClass == category:
for cogfile in os.listdir(f'./{cogsDir}/{category}'):
if cogfile.endswith('.py'):
reloadCog(f'./{cogsDir}/{category}/{cogfile}')
loadCogs('controlcommands')
loadCogs('events')
loadCogs('botcommands')
loadCogs('slashcommands')
if all([len(yaml_load(configFile)[x]['timeslots']) > 0 for x in yaml_load(configFile)]):
loadCog(f'./{cogsDir}/slashcommands/secondary/manipulate_timeslots.py')
if all([len(yaml_load(configFile)[x]['membership']) > 0 for x in yaml_load(configFile)]):
loadCog(f'./{cogsDir}/slashcommands/secondary/edit_membership.py')
client.run(os.getenv('TEST_3_TOKEN'))