-
Notifications
You must be signed in to change notification settings - Fork 0
/
launcher.py
49 lines (34 loc) · 1.11 KB
/
launcher.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
import logging
from argparse import ArgumentParser
from discord.ext import commands
from bot.rick import Rick
from utils.helpers import setup_logger
logger = logging.getLogger("launcher")
def start(_args):
debug = _args.debug
dev_bot = _args.dev_bot
setup_logger("launcher", debug)
setup_logger("bot", debug)
setup_logger("utils", debug)
setup_logger("cogs", debug)
setup_logger("discord", False)
logger.info(f"Starting bot.")
bot = Rick()
try:
bot.run(bot=("main" if not dev_bot else "dev"))
finally:
try:
exit_code = bot._exit_code
except:
logger.info("Bot's exit code could not be retrieved.")
exit_code = 0
logger.info(f"Bot closed with exit code {exit_code}.")
exit(exit_code)
def parse_args():
parser = ArgumentParser(description="Start Rickroll Detector bot.")
parser.add_argument("--debug", "-d", action="store_true")
parser.add_argument("--dev-bot", "-dev", action="store_true")
return parser.parse_args()
if __name__ == "__main__":
args = parse_args()
start(args)