Experimental Discord bot written in Python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637
  1. from discord import Guild, TextChannel
  2. from discord.ext import commands
  3. from storage import Storage
  4. class ConfigCog(commands.Cog):
  5. """
  6. Cog for handling general bot configuration.
  7. """
  8. def __init__(self, bot):
  9. self.bot = bot
  10. @commands.group(
  11. brief='Manages general bot configuration'
  12. )
  13. @commands.has_permissions(ban_members=True)
  14. @commands.guild_only()
  15. async def config(self, context: commands.Context):
  16. 'Command group'
  17. if context.invoked_subcommand is None:
  18. await context.send_help()
  19. @config.command(
  20. name='setoutputchannel',
  21. brief='Sets the channel where mod communications occur',
  22. description='Run this command in the channel where bot messages ' +
  23. 'intended for server moderators should be sent. Other bot messages ' +
  24. 'may still be posted in the channel a command was invoked in. If ' +
  25. 'no output channel is set, mod-related messages will not be posted!',
  26. )
  27. async def config_setoutputchannel(self, context: commands.Context):
  28. 'Command handler'
  29. guild: Guild = context.guild
  30. channel: TextChannel = context.channel
  31. state: dict = Storage.state_for_guild(context.guild)
  32. state['output_channel_id'] = context.channel.id
  33. Storage.save_guild_state(context.guild)
  34. await context.message.reply(f'Output channel set to {channel.name}', mention_author=False)