-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
59 lines (44 loc) · 1.5 KB
/
main.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
51
52
53
54
55
56
57
58
59
import asyncio
import json
import os
import discord
import discord.ext.commands as commands
import logging
logging.basicConfig(level=logging.INFO)
log = logging.getLogger("bot")
log.setLevel(logging.DEBUG)
log.info("Loading Config Values")
config = {}
prod_flag = os.getenv("PROD")
log.info(f"PROD Flag = {prod_flag}")
if bool(prod_flag):
config["Token"] = os.getenv("TOKEN")
config["LeaderboardTitle"] = os.getenv("LEADERBOARDTITLE")
config["LeaderboardChannel"] = int(os.getenv("LEADERBOARDCHANNEL"))
config["LeaderboardInvite"] = os.getenv("LEADERBOARDINVITE")
config["SessionCookie"] = os.getenv("SESSIONCOOKIE")
config["LeaderboardEndpoint"] = os.getenv("LEADERBOARDENDPOINT")
else:
with open("config.json") as f:
config = json.loads(f.read())
log.info("Config Values Loaded")
class AoCLeaderboardBot(commands.Bot):
def __init__(self, config, *args, **kwargs):
super().__init__(*args, **kwargs)
self.config: dict[str, str] = config
log.info("Leaderboard Cog loaded")
async def setup_hook(self):
await self.load_extension("leaderboard")
log.info("Leaderboard Bot started up")
async def on_message(self, message):
pass
async def main():
log.info("Running Bot")
bot = AoCLeaderboardBot(
config, command_prefix=None, intents=discord.Intents.default()
)
async with bot:
log.info("Bot starting up")
await bot.start(config["Token"])
if __name__ == "__main__":
asyncio.run(main())