Experimental Discord bot written in Python
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

config.py 1.2KB

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