| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- """
- Rocketbot Discord bot. Relies on a configured config.py (copy config.py.sample
- for a template).
-
- Author: Ian Albert (@rocketsoup)
- Date: 2021-11-11
- """
- from discord import Intents
- from discord.ext import commands
-
- from config import CONFIG
- from cogs.configcog import ConfigCog
- from cogs.crosspostcog import CrossPostCog
- from cogs.generalcog import GeneralCog
- from cogs.joinraidcog import JoinRaidCog
- from cogs.patterncog import PatternCog
- from cogs.urlspamcog import URLSpamCog
-
- CURRENT_CONFIG_VERSION = 3
- if (CONFIG.get('__config_version') or 0) < CURRENT_CONFIG_VERSION:
- # If you're getting this error, it means something changed in config.py's
- # format. Consult config.py.sample and compare it to your own config.py.
- # Rename/move any values as needed. When satisfied, update "__config_version"
- # to the value in config.py.sample.
- raise RuntimeError('config.py format may be outdated. Review ' +
- 'config.py.sample, update the "__config_version" field to ' +
- f'{CURRENT_CONFIG_VERSION}, and try again.')
-
- class Rocketbot(commands.Bot):
- """
- Bot subclass
- """
- def __init__(self, command_prefix, **kwargs):
- super().__init__(command_prefix, **kwargs)
-
- intents = Intents.default()
- intents.messages = True # pylint: disable=assigning-non-slot
- intents.members = True # pylint: disable=assigning-non-slot
- bot = Rocketbot(command_prefix=CONFIG['command_prefix'], intents=intents)
-
- # Core
- bot.add_cog(GeneralCog(bot))
- bot.add_cog(ConfigCog(bot))
-
- # Optional
- bot.add_cog(CrossPostCog(bot))
- bot.add_cog(JoinRaidCog(bot))
- bot.add_cog(PatternCog(bot))
- bot.add_cog(URLSpamCog(bot))
-
- bot.run(CONFIG['client_token'], bot=True, reconnect=True)
- print('\nBot aborted')
|