Experimental Discord bot written in Python
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

generalcog.py 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from discord.ext import commands
  2. from cogs.basecog import BaseCog
  3. from storage import ConfigKey, Storage
  4. class GeneralCog(BaseCog):
  5. def __init__(self, bot: commands.Bot):
  6. super().__init__(bot)
  7. self.is_connected = False
  8. self.is_ready = False
  9. @commands.Cog.listener()
  10. async def on_connect(self):
  11. print('on_connect')
  12. self.is_connected = True
  13. @commands.Cog.listener()
  14. async def on_ready(self):
  15. print('on_ready')
  16. self.is_ready = True
  17. @commands.command(
  18. brief='Posts a test warning in the configured warning channel.'
  19. )
  20. @commands.has_permissions(ban_members=True)
  21. @commands.guild_only()
  22. async def testwarn(self, context):
  23. if Storage.get_config_value(context.guild, ConfigKey.WARNING_CHANNEL_ID) is None:
  24. await context.message.reply(
  25. 'No warning channel set!',
  26. mention_author=False)
  27. else:
  28. await self.warn(context.guild,
  29. f'Test warning message (requested by {context.author.name})')
  30. @commands.command()
  31. async def hello(self, context):
  32. await context.message.reply(
  33. f'Hey, {context.author.name}!',
  34. mention_author=False)