-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
43 lines (33 loc) · 1.26 KB
/
run.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
import logging, traceback
from datetime import datetime
from lib import utils
from bot.bot import BonfireBot
# Main Program
def run(logger):
TOKEN, PREFIX = utils.get_discord_config()
logger.info("Starting Discord bot...")
bot = BonfireBot(TOKEN, PREFIX)
bot.run()
if __name__ == '__main__':
try:
# Setup Logging
timeNow = datetime.now().strftime("%Y/%m/%d - %H:%M:%S")
config = utils.get_config()
if(config["app"]["logging"]):
logging.basicConfig(
handlers=[logging.FileHandler(filename=f"logs/{timeNow}.txt",
encoding='utf-8', mode='a+'),
logging.StreamHandler()],
level=logging.INFO,
format='[%(asctime)s] %(levelname)s:%(name)s - %(message)s'
)
else:
logging.basicConfig(
handlers=[logging.StreamHandler()],
level=logging.INFO,
format='[%(asctime)s] %(levelname)s:%(name)s - %(message)s'
)
logging.info(f"Bonfire bot logs - {timeNow}")
run(logging.getLogger(__name__))
except Exception as e:
logging.error(f"{e}\n\n{traceback.format_exc()}")