This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·52 lines (43 loc) · 1.47 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
#!/usr/bin/env python3
from asyncio import run
from sys import argv
from typing import cast
from src import DEBUG_TOKEN, DISCORD_TOKEN
from src.client import bot
from src.datagen.icons import download_hero_icons
from src.datagen.items import download_item_icons
def usage() -> None:
print(f"Usage: {argv[0]} [run | debug | gen] ")
print(" run: run the bot ")
print(" debug: debug the the bot ")
print(" gen: generates the data for the bot ")
print(" heroes: generates the hero icons ")
print(" items: geenrates the item icons ")
def crash(msg: str) -> None:
print(msg)
usage()
exit(1)
def main() -> None:
if len(argv) < 2:
crash("Not enough arguments.")
ap: int = 1
if argv[ap] == "run":
if not DISCORD_TOKEN:
crash("'DISCORD_TOKEN' environment variable is not set up properly.")
bot.run(cast(str, DISCORD_TOKEN))
elif argv[ap] == "debug":
if not DEBUG_TOKEN:
crash("'DEBUG_TOKEN' environment variable is not set up properly.")
crash("Not implemented")
elif argv[ap] == "gen":
ap += 1
if argv[ap] == "heroes":
run(download_hero_icons())
elif argv[ap] == "items":
run(download_item_icons())
else:
crash(f"Unknown subcommand {argv[ap]} for `gen` commmand")
else:
crash(f"Unknown command {argv[ap]}")
if __name__ == "__main__":
main()