-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (33 loc) · 1.05 KB
/
main.py
File metadata and controls
38 lines (33 loc) · 1.05 KB
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
import os, coloredlogs, logging, traceback
from colorama import Fore
#Setup logging so we know what is going on
coloredlogs.install(level="INFO", fmt="%(asctime)s %(name)s[%(process)d] %(levelname)s %(message)s")
logger = logging.getLogger("Reko")
file_handler = logging.FileHandler("SEVERE.log")
file_handler.setLevel(logging.ERROR)
file_handler.setFormatter(logging.Formatter(fmt="%(asctime)s %(name)s[%(process)d] %(levelname)s %(message)s"))
logger.addHandler(file_handler)
#try getting bot
try:
from src.bot import bot
except Exception as e:
if e == KeyboardInterrupt:
pass
else:
logging.critical("Something fatal occured in the bot")
logger.error(traceback.format_exc())
#dotenvs
from dotenv import load_dotenv
#Load Token
load_dotenv("src/secrets/.env")
token = os.getenv("TOKEN")
#Run bot
if __name__ == "__main__":
try:
if token != None:
bot.run(token)
else:
logger.error("Failed to start bot")
logger.error("TOKEN env not found")
except:
pass