-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
39 lines (35 loc) · 1006 Bytes
/
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
from argparse import ArgumentParser
from dotenv import load_dotenv
import logging
from core import Bot
if __name__ == "__main__":
parser = ArgumentParser(prog="Bot")
parser.add_argument(
"-d",
"--debug",
dest="cogs",
action="extend",
nargs="*",
help="run in debug mode",
)
parser.add_argument(
"-s",
"--sync",
action="store_true",
help="synchronize commands",
)
args = parser.parse_args()
debug = args.cogs is not None
load_dotenv(".env")
logger = logging.getLogger("discord")
logger.setLevel(logging.DEBUG if debug else logging.INFO)
handler = logging.FileHandler(
filename="discord.log", encoding="utf-8", mode="w"
)
handler.formatter = logging.Formatter(
"[%(asctime)s %(levelname)s] %(name)s: %(message)s",
"%d/%m/%y %H:%M:%S",
)
logger.addHandler(handler)
bot = Bot()
bot.run(debug=debug, cogs=args.cogs, sync=args.sync)