forked from viveksantayana/geas-bot
Finished /config subcommands
Prior to abstraction to generic /config commands with multiple keyed arguments
This commit is contained in:
@ -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))
|
Reference in New Issue
Block a user