Finished /config subcommands

Prior to abstraction to generic /config commands with multiple keyed arguments
This commit is contained in:
Vivek Santayana 2021-07-18 00:43:44 +01:00
parent 241403f5fb
commit 3d937fffea
4 changed files with 173 additions and 12 deletions

14
TODO.md
View File

@ -43,17 +43,17 @@
- [x] Mod Channel Deleted
## Commands
- [ ] Configure Bot function and sub commands
- [x] Configure Bot function and sub commands
> - [x] botrole (role group)
> - [ ] committeerole (role group)
> - [x] committeerole (role group)
> - [x] modchannel (channel group)
> - [x] help channel (channel group)
> - [x] signup channel (channel group)
> - [ ] newcomer role (role group)
> - [ ] returning player role (role group)
> - [ ] student role (role group)
> - [ ] help notifications (notification group)
> - [ ] signup notifications (notification group)
> - [x] newcomer role (role group)
> - [x] returning player role (role group)
> - [x] student role (role group)
> - [x] help notifications (notification group)
> - [x] signup notifications (notification group)
- [ ] Set up command permissions
> - [ ] Slash Commands
>> - [x] Admin Commands

View File

@ -185,8 +185,8 @@ def parseConfigCheck(missingKeys: list):
output = ''.join([output, f"- The `administrator` role(s) for the guild\n"])
if e2 == 'committee':
output = ''.join([output, f"- The `Committee` role for the guild\n"])
if e2 == 'bots':
output = ''.join([output, f"- The `Bots` role for the guild\n"])
if e2 == 'bot':
output = ''.join([output, f"- The `Bot` role for the guild\n"])
if e2 == 'newcomer':
output = ''.join([output, f"- The `Newcomer` role for the guild\n"])
if e2 == 'returning':

View File

@ -76,9 +76,117 @@ class Configuration(commands.Cog):
conf = yaml_load(configFile)
if 'roles' not in conf[str(ctx.guild.id)]:
conf[str(ctx.guild.id)]['roles'] = {}
conf[str(ctx.guild.id)]['roles']['bots'] = int(role.id)
conf[str(ctx.guild.id)]['roles']['bot'] = int(role.id)
yaml_dump(conf, configFile)
await ctx.send(f'```The `botrole` for the guild `{ctx.guild.name}` has been set to `{role.name}`.```')
await ctx.send(f'```The `bot` role for the guild `{ctx.guild.name}` has been set to `{role.name}`.```')
@cog_ext.cog_subcommand(
base='config',
subcommand_group='role',
name='committee',
description='Designate the role used by committee members.',
# base_description='Commands for configuring the various parameters of the Guild',
# base_default_permission=False,
# base_permissions=permissions,
# subcommand_group_description='Designates the various key command roles for the guild.',
guild_ids=guild_ids,
options=[
create_option(
name='role',
description='The role assigned to committee members.',
option_type=8,
required=True
)
]
)
async def _config_role_committee(self, ctx:SlashContext, role:discord.Role):
conf = yaml_load(configFile)
if 'roles' not in conf[str(ctx.guild.id)]:
conf[str(ctx.guild.id)]['roles'] = {}
conf[str(ctx.guild.id)]['roles']['committee'] = int(role.id)
yaml_dump(conf, configFile)
await ctx.send(f'```The `committee` role for the guild `{ctx.guild.name}` has been set to `{role.name}`.```')
@cog_ext.cog_subcommand(
base='config',
subcommand_group='role',
name='newcomer',
description='Role for members new to the guild.',
# base_description='Commands for configuring the various parameters of the Guild',
# base_default_permission=False,
# base_permissions=permissions,
# subcommand_group_description='Designates the various key command roles for the guild.',
guild_ids=guild_ids,
options=[
create_option(
name='role',
description='The role assigned to new members.',
option_type=8,
required=True
)
]
)
async def _config_role_newcomer(self, ctx:SlashContext, role:discord.Role):
conf = yaml_load(configFile)
if 'roles' not in conf[str(ctx.guild.id)]:
conf[str(ctx.guild.id)]['roles'] = {}
conf[str(ctx.guild.id)]['roles']['newcomer'] = int(role.id)
yaml_dump(conf, configFile)
await ctx.send(f'```The `newcomer` role for the guild `{ctx.guild.name}` has been set to `{role.name}`.```')
@cog_ext.cog_subcommand(
base='config',
subcommand_group='role',
name='returning_player',
description='Role for returning players re-joining their game.',
# base_description='Commands for configuring the various parameters of the Guild',
# base_default_permission=False,
# base_permissions=permissions,
# subcommand_group_description='Designates the various key command roles for the guild.',
guild_ids=guild_ids,
options=[
create_option(
name='role',
description='Role for returning players continuing in their games.',
option_type=8,
required=True
)
]
)
async def _config_role_returning_player(self, ctx:SlashContext, role:discord.Role):
conf = yaml_load(configFile)
if 'roles' not in conf[str(ctx.guild.id)]:
conf[str(ctx.guild.id)]['roles'] = {}
conf[str(ctx.guild.id)]['roles']['returning_player'] = int(role.id)
yaml_dump(conf, configFile)
await ctx.send(f'```The `returning player` role for the guild `{ctx.guild.name}` has been set to `{role.name}`.```')
@cog_ext.cog_subcommand(
base='config',
subcommand_group='role',
name='student',
description='Role for students.',
# base_description='Commands for configuring the various parameters of the Guild',
# base_default_permission=False,
# base_permissions=permissions,
# subcommand_group_description='Designates the various key command roles for the guild.',
guild_ids=guild_ids,
options=[
create_option(
name='role',
description='The role assigned to students.',
option_type=8,
required=True
)
]
)
async def _config_role_student(self, ctx:SlashContext, role:discord.Role):
conf = yaml_load(configFile)
if 'roles' not in conf[str(ctx.guild.id)]:
conf[str(ctx.guild.id)]['roles'] = {}
conf[str(ctx.guild.id)]['roles']['student'] = int(role.id)
yaml_dump(conf, configFile)
await ctx.send(f'```The `student` role for the guild `{ctx.guild.name}` has been set to `{role.name}`.```')
@cog_ext.cog_subcommand(
base='config',
@ -161,6 +269,59 @@ class Configuration(commands.Cog):
yaml_dump(conf, configFile)
await ctx.send(f'```The `help` channel for the guild `{ctx.guild.name}` has been set to `{channel.name}`.```')
@cog_ext.cog_subcommand(
base='config',
subcommand_group='notifications',
name='help',
description='Configure whether the bot monitors the `help` channel and notifies Committee about posts.',
# base_description='Commands for configuring the various parameters of the Guild',
# base_default_permission=False,
# base_permissions=permissions,
subcommand_group_description='Configures whether the bot monitors and responds to posts in key channels.',
guild_ids=guild_ids,
options=[
create_option(
name='notifications',
description='Whether or not the bot monitors the help channel for posts.',
option_type=5,
required=True
)
]
)
async def _config_notifications_help(self, ctx:SlashContext, input:bool):
conf = yaml_load(configFile)
if 'notifications' not in conf[str(ctx.guild.id)]:
conf[str(ctx.guild.id)]['notifications'] = {}
conf[str(ctx.guild.id)]['notifications']['help'] = input
yaml_dump(conf, configFile)
await ctx.send(f'```Notifications for posts in the `help` channel for the guild `{ctx.guild.name}` has been set to `{input}`.```')
@cog_ext.cog_subcommand(
base='config',
subcommand_group='notifications',
name='signup',
description='Configure whether the bot monitors the `signup` channel and notifies Committee about posts.',
# base_description='Commands for configuring the various parameters of the Guild',
# base_default_permission=False,
# base_permissions=permissions,
subcommand_group_description='Configures whether the bot monitors and responds to posts in key channels.',
guild_ids=guild_ids,
options=[
create_option(
name='notifications',
description='Whether or not the bot monitors the help channel for posts.',
option_type=5,
required=True
)
]
)
async def _config_notifications_signup(self, ctx:SlashContext, input:bool):
conf = yaml_load(configFile)
if 'notifications' not in conf[str(ctx.guild.id)]:
conf[str(ctx.guild.id)]['notifications'] = {}
conf[str(ctx.guild.id)]['notifications']['signup'] = input
yaml_dump(conf, configFile)
await ctx.send(f'```Notifications for posts in the `signup` channel for the guild `{ctx.guild.name}` has been set to `{input}`.```')
def setup(client):
client.add_cog(Configuration(client))

View File

@ -14,7 +14,7 @@ guild_id_string:
- 0 # List
# For admins, at least one needs to be defined.
# committee notifications is optional so is not necessary in blueprint.
bots: 0
bot: 0
# newcomer role is optional
# returning player role is optional
# student role is optional