-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.py
More file actions
63 lines (52 loc) · 1.71 KB
/
index.py
File metadata and controls
63 lines (52 loc) · 1.71 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
53
54
55
56
57
58
59
60
61
62
63
import os
import traceback
from dotenv import find_dotenv, load_dotenv
from motor.motor_asyncio import AsyncIOMotorClient
from typing import Any, Coroutine
from discord import Intents, Object
from discord.ext.commands import Bot
from encryption import Encryption
class System(Bot):
def __init__(self):
self.version = "0.0.1a"
self.loaded_extension_list = []
self.unloaded_extension_list = []
self.internal_error_occured = False
intents = Intents.all()
super().__init__(intents = intents, command_prefix = "/")
async def start(self, *args, **kwargs):
self.core_guild = int(os.getenv("GUILD"))
await super().start(*args, **kwargs)
async def sync_commands(self):
await self.tree.sync(guild = Object(id = self.core_guild))
await self.tree.sync()
async def setup_hook(self) -> Coroutine[Any, Any, None]:
self.encryption = Encryption()
try:
self.encryption.load_credentials()
except FileNotFoundError:
self.encryption.generate_credentials()
self.database = AsyncIOMotorClient(
os.getenv("MONGO"),
tls = True,
tlsCertificateKeyFile = "mongo_cert.pem"
)["disect"]
self.chatsync_db = AsyncIOMotorClient(
os.getenv("MONGO"),
tls = True,
tlsCertificateKeyFile = "mongo_cert.pem"
)["channelsync"]
for file in os.listdir("./cogs"):
if file.endswith(".py"):
try:
await self.load_extension(f"cogs.{file[:-3]}")
self.loaded_extension_list.append(file[:-3])
print(f"Loaded \"{file[:-3]}\" extension")
except Exception as error:
self.unloaded_extension_list.append(file[:-3])
traceback.print_exc(error)
self.loop.create_task(self.sync_commands())
if __name__ == "__main__":
load_dotenv(find_dotenv())
bot = System()
bot.run(os.getenv("TOKEN"))