diff options
author | 2022-07-23 17:17:29 +0200 | |
---|---|---|
committer | 2022-07-23 17:17:29 +0200 | |
commit | 94c4b408f1afa604ae6907aa28ab694870af20f2 (patch) | |
tree | 6a93d9648d033a4e535424defe3eaa407eb41dc5 /dev/bot/__init__.py | |
parent | Merge pull request #99 from python-discord/dependabot/pip/pre-commit-2.20.0 (diff) | |
parent | Document Sample Project Environment Variables (diff) |
Merge pull request #107 from python-discord/better-development
Fix Docker Compose & Add Boilerplate Project
Diffstat (limited to 'dev/bot/__init__.py')
-rw-r--r-- | dev/bot/__init__.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/dev/bot/__init__.py b/dev/bot/__init__.py new file mode 100644 index 00000000..71871209 --- /dev/null +++ b/dev/bot/__init__.py @@ -0,0 +1,24 @@ +import asyncio +import logging +import os +import sys + +import botcore + +if os.name == "nt": + # Change the event loop policy on Windows to avoid exceptions on exit + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) + +# Some basic logging to get existing loggers to show +logging.getLogger().addHandler(logging.StreamHandler()) +logging.getLogger().setLevel(logging.DEBUG) +logging.getLogger("discord").setLevel(logging.ERROR) + + +class Bot(botcore.BotBase): + """Sample Bot implementation.""" + + async def setup_hook(self) -> None: + """Load extensions on startup.""" + await super().setup_hook() + asyncio.create_task(self.load_extensions(sys.modules[__name__])) |