from discord import Guild, TextChannel from discord.ext import commands from storage import Storage class ConfigCog(commands.Cog): """ Cog for handling general bot configuration. """ def __init__(self, bot): self.bot = bot @commands.group( brief='Manages general bot configuration' ) @commands.has_permissions(ban_members=True) @commands.guild_only() async def config(self, context: commands.Context): 'Command group' if context.invoked_subcommand is None: await context.send_help() @config.command( name='setoutputchannel', brief='Sets the channel where mod communications occur', description='Run this command in the channel where bot messages ' + 'intended for server moderators should be sent. Other bot messages ' + 'may still be posted in the channel a command was invoked in. If ' + 'no output channel is set, mod-related messages will not be posted!', ) async def config_setoutputchannel(self, context: commands.Context): 'Command handler' guild: Guild = context.guild channel: TextChannel = context.channel state: dict = Storage.state_for_guild(context.guild) state['output_channel_id'] = context.channel.id Storage.save_guild_state(context.guild) await context.message.reply(f'Output channel set to {channel.name}', mention_author=False)