-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.py
50 lines (40 loc) · 1.71 KB
/
index.py
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
import logging
import os
import pkgutil
from interactions import Client, listen, Activity, ActivityType, Intents, Status
from models.internal.internal_cache import InternalCache
logging.basicConfig()
log = logging.getLogger("VANGUARD")
log.setLevel(logging.DEBUG)
class Bot(Client):
# Automatically sets the bot to debug mode when the env var is set to it.
debug: bool = bool(os.getenv("DEBUG")) or False
internal_cache: InternalCache
@listen()
async def on_startup(self):
log.info(f"Logged in as {self.user.username}")
await self.change_presence(
status=Status.ONLINE,
activity=Activity(name="VALORANT", type=ActivityType.PLAYING),
)
if __name__ == "__main__":
bot = Bot(
activity=Activity(name="Loading…", type=ActivityType.PLAYING),
intents=Intents.ALL,
fetch_members=True,
status=Status.DND,
)
bot.internal_cache = InternalCache(bot)
# Removing automatic updates for now because I need a more stable version control rather than just a file containing the version.
# Once this has been switched to a database, I can re-activate it.
extension_blacklist = ["updates"]
# I am not using the prefix here (prefix="extensions."), because I'd have to remove the extension prefix from everything else other than loading. It is more convenient to add it once in the loading process.
extension_names = [
m.name
for m in pkgutil.iter_modules(["extensions"])
if m.name not in extension_blacklist
]
for name in extension_names:
bot.load_extension(f"extensions.{name}")
log.info(f"Loaded -> {name}")
bot.start(bot.debug and os.environ["DEV_TOKEN"] or os.environ["TOKEN"])