from discord import Guild, TextChannel from discord.ext import commands from storage import StateKey, Storage from cogs.base import BaseCog class ConfigCog(BaseCog): """ 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='setwarningchannel', brief='Sets the channel where mod warnings are posted', 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_setwarningchannel(self, context: commands.Context): 'Command handler' guild: Guild = context.guild channel: TextChannel = context.channel self.save_setting(guild, StateKey.WARNING_CHANNEL_ID, context.channel.id) await context.message.reply(f'Warning channel set to {channel.name}', mention_author=False)