aboutsummaryrefslogtreecommitdiffstats
path: root/dev/bot/__init__.py
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-07-23 14:47:06 +0200
committerGravatar Hassan Abouelela <[email protected]>2022-07-23 17:10:52 +0200
commitafa46c4abfc73c8791742ed2ece886776823e8ab (patch)
treeb0032b561f63030c61b3174e55f1f0c3ac321b69 /dev/bot/__init__.py
parentMark aiodns As An Explicit Dependency (diff)
Add Sample Project With Boilerplate
Adds a bare-bones discord.py bot using features from bot-core, to be used for quickly prototyping and testing out bot-core features. Signed-off-by: Hassan Abouelela <[email protected]>
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__]))