-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
52 lines (38 loc) · 1.41 KB
/
bot.py
File metadata and controls
52 lines (38 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import disnake
from disnake.ext import commands
from os import environ
from asyncpg import create_pool
class AcadiaBot(commands.Bot):
def __init__(self, *args, **kwargs):
self.db = None
self.loop.run_until_complete(self.init_database())
super().__init__(
command_prefix='-',
test_guilds = [909208958735110194, ],
intents = disnake.Intents.all()
)
autoload_extensions = [
'cogs.testCog',
'cogs.mathCog',
'cogs.repoManagementCog'
]
for ext in autoload_extensions:
self.load_extension(ext)
async def init_database(self, *args, **kwargs) -> None:
"""Initializes the database connection pool
"""
self.db = await create_pool(
database = environ.get("DB_NAME"),
username = environ.get("DB_USERNAME"),
password = environ.get("DB_PASSWORD")
)
await self.run_database_schema()
async def run_database_schema(self, *args, **kwargs) -> None:
"""Runs inital queries to setup the database
"""
with open("./schema.sql", 'r', encoding='utf-8') as schema:
await self.db.execute(schema.read())
return
if __name__ == "__main__":
acadiaBotInstance = AcadiaBot()
acadiaBotInstance.run(environ.get('BOT_TOKEN', None)) # We do a little environment variables