aboutsummaryrefslogtreecommitdiffstats
path: root/dev/bot/__init__.py
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-07-23 17:17:29 +0200
committerGravatar GitHub <[email protected]>2022-07-23 17:17:29 +0200
commit94c4b408f1afa604ae6907aa28ab694870af20f2 (patch)
tree6a93d9648d033a4e535424defe3eaa407eb41dc5 /dev/bot/__init__.py
parentMerge pull request #99 from python-discord/dependabot/pip/pre-commit-2.20.0 (diff)
parentDocument 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__.py24
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__]))