-
Notifications
You must be signed in to change notification settings - Fork 0
/
discord_bot.py
44 lines (31 loc) · 1023 Bytes
/
discord_bot.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
import argparse
import asyncio
import logging
import discord.ext.commands as cmd
import database as db
def make_argparse() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser()
parser.add_argument("-q", "--quiet", action="store_true")
parser.add_argument("-d", "--debug", action="store_true")
return parser
def main():
args = make_argparse().parse_args()
db.setup_logging(
to_stdout=not args.quiet,
local_level=(logging.DEBUG if args.debug else logging.INFO),
# local_level=logging.DEBUG
)
logger = db.get_logger(__name__)
bot = cmd.Bot()
bot_info = db.get_json_data(__name__)
bot.owner_ids = bot_info.get("owners", [])
key = bot_info["key"]
db.init_box(bot_info["crypt"])
bot.load_extensions("system", *bot_info.get("extensions", []))
del bot_info
asyncio.run(db.init_tables())
bot.run(key)
db.delete_temp_file()
logger.info("Shutdown Complete, End of Process")
if __name__ == "__main__":
main()