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

rocketbot.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. """
  2. Rocketbot Discord bot. Relies on a configured config.py (copy config.py.sample for a template) and
  3. the sqlite database rocketbot.db (copy rocketbot.db.sample for a blank database).
  4. Author: Ian Albert (@rocketsoup)
  5. Date: 2021-11-11
  6. """
  7. from discord import Intents
  8. from discord.ext import commands
  9. from config import CONFIG
  10. from cogs.configcog import ConfigCog
  11. from cogs.crosspostcog import CrossPostCog
  12. from cogs.generalcog import GeneralCog
  13. from cogs.joinraidcog import JoinRaidCog
  14. from cogs.patterncog import PatternCog
  15. from cogs.urlspamcog import URLSpamCog
  16. CURRENT_CONFIG_VERSION = 1
  17. if (CONFIG.get('__config_version') or 0) < CURRENT_CONFIG_VERSION:
  18. raise RuntimeError('config.py format may be outdated. Review ' +
  19. 'config.py.sample, update the "__config_version" field to ' +
  20. f'{CURRENT_CONFIG_VERSION}, and try again.')
  21. class Rocketbot(commands.Bot):
  22. def __init__(self, command_prefix, **kwargs):
  23. super().__init__(command_prefix, **kwargs)
  24. intents = Intents.default()
  25. intents.messages = True
  26. intents.members = True # To get join/leave events
  27. bot = Rocketbot(command_prefix=CONFIG['command_prefix'], intents=intents)
  28. bot.add_cog(GeneralCog(bot))
  29. bot.add_cog(ConfigCog(bot))
  30. bot.add_cog(JoinRaidCog(bot))
  31. bot.add_cog(CrossPostCog(bot))
  32. bot.add_cog(PatternCog(bot))
  33. bot.add_cog(URLSpamCog(bot))
  34. bot.run(CONFIG['client_token'], bot=True, reconnect=True)
  35. print('\nBot aborted')