Experimental Discord bot written in Python
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

rocketbot.py 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. """
  2. Rocketbot Discord bot. Relies on a configured config.py (copy config.py.sample
  3. for a template).
  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 = 3
  17. if (CONFIG.get('__config_version') or 0) < CURRENT_CONFIG_VERSION:
  18. # If you're getting this error, it means something changed in config.py's
  19. # format. Consult config.py.sample and compare it to your own config.py.
  20. # Rename/move any values as needed. When satisfied, update "__config_version"
  21. # to the value in config.py.sample.
  22. raise RuntimeError('config.py format may be outdated. Review ' +
  23. 'config.py.sample, update the "__config_version" field to ' +
  24. f'{CURRENT_CONFIG_VERSION}, and try again.')
  25. class Rocketbot(commands.Bot):
  26. def __init__(self, command_prefix, **kwargs):
  27. super().__init__(command_prefix, **kwargs)
  28. intents = Intents.default()
  29. intents.messages = True
  30. intents.members = True # To get join/leave events
  31. bot = Rocketbot(command_prefix=CONFIG['command_prefix'], intents=intents)
  32. # Core
  33. bot.add_cog(GeneralCog(bot))
  34. bot.add_cog(ConfigCog(bot))
  35. # Optional
  36. bot.add_cog(CrossPostCog(bot))
  37. bot.add_cog(JoinRaidCog(bot))
  38. bot.add_cog(PatternCog(bot))
  39. bot.add_cog(URLSpamCog(bot))
  40. bot.run(CONFIG['client_token'], bot=True, reconnect=True)
  41. print('\nBot aborted')