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

@ -54,48 +54,5 @@ class Control(commands.Cog, name='Cog Control Commands'):
elif status:
await ctx.reply(f"```The Bot's configurations for the guild {ctx.guild.name} are in order. The Bot is ready to interact with the guild.```")
@commands.command(
name='lockconfig',
description='Administrator command that locks the /config commands, preventing any accidental changes to configurations.',
brief='Toggle locking /config command.',
aliases=['configlock','lock','lockdownconfig']
)
async def _lockconfig(self, ctx:commands.Context, toggle:str):
if toggle == 'on':
o = ''
if self.client.get_cog('Configuration Commands') is not None:
unloadCog(f'./{cogsDir}/slashcommands/config.py')
o = ''.join([o,'Configuration Lock turned on. `/config` command has been disabled.'])
else:
o = ''.join([o,'`/config` command has already been disabled.'])
if self.client.get_cog('Manipulate Timeslots') is not None:
unloadCog(f'./{cogsDir}/slashcommands/secondary/manipulate_timeslots.py')
o = ''.join([o,'\nTimeslot configuration sub-commands have been disabled.'])
else:
o = ''.join([o,'\nTimeslot configuration sub-commands have already been disabled.'])
await ctx.reply(f'```{o}```')
await self.client.slash.sync_all_commands()
elif toggle == 'off':
o = ''
if self.client.get_cog('Configuration Commands') is None:
loadCog(f'./{cogsDir}/slashcommands/config.py')
await self.client.slash.sync_all_commands()
o = ''.join([o,'Configuration Lock turned off. `/config` command has been re-enabled.'])
else:
o = ''.join([o,'`/config` command has already been enabled.'])
if self.client.get_cog('Manipulate Timeslots') is None:
if all([len(yaml_load(configFile)[x]['timeslots']) > 0 for x in yaml_load(configFile)]):
loadCog(f'./{cogsDir}/slashcommands/secondary/manipulate_timeslots.py')
await self.client.slash.sync_all_commands()
o = ''.join([o,'\nTimeslot configuration sub-commands have been re-enabled.'])
else:
o = ''.join([o,'\nTimeslot configuration sub-commands are not re-enabled because there are no configured timeslots for the guild.'])
else:
o = ''.join([o,'\nTimeslot configuration sub-commands have already been enabled.'])
await ctx.reply(f'```{o}```')
await self.client.slash.sync_all_commands()
else:
raise commands.CommandError('Invalid argument. `lockconfig` command only accepts the arguments `on` or `off`.')
def setup(client):
client.add_cog(Control(client))