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.

generalcog.py 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from discord.ext import commands
  2. from cogs.basecog import BaseCog
  3. from storage import StateKey, Storage
  4. class GeneralCog(BaseCog):
  5. def __init__(self, bot: commands.Bot):
  6. self.bot = 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_state_value(context.guild, StateKey.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)