aboutsummaryrefslogtreecommitdiffstats
path: root/dev/bot/__main__.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/__main__.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/__main__.py')
-rw-r--r--dev/bot/__main__.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/dev/bot/__main__.py b/dev/bot/__main__.py
new file mode 100644
index 00000000..00ebdefc
--- /dev/null
+++ b/dev/bot/__main__.py
@@ -0,0 +1,34 @@
+import asyncio
+import os
+
+import aiohttp
+import discord
+import dotenv
+from discord.ext import commands
+
+import botcore
+from . import Bot
+
+dotenv.load_dotenv()
+botcore.utils.apply_monkey_patches()
+
+roles = os.getenv("ALLOWED_ROLES")
+roles = [int(role) for role in roles.split(",")] if roles else []
+
+bot = Bot(
+ guild_id=int(os.getenv("GUILD_ID")),
+ http_session=None, # type: ignore # We need to instantiate the session in an async context
+ allowed_roles=roles,
+ command_prefix=commands.when_mentioned_or(os.getenv("PREFIX", "!")),
+ intents=discord.Intents.all(),
+ description="Bot-core test bot.",
+)
+
+
+async def main() -> None:
+ """Run the bot."""
+ bot.http_session = aiohttp.ClientSession()
+ async with bot:
+ await bot.start(os.getenv("TOKEN"))
+
+asyncio.run(main())