-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (42 loc) · 1.96 KB
/
main.py
File metadata and controls
48 lines (42 loc) · 1.96 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
39
40
41
42
43
44
45
46
47
48
# Note: Had to do SO many workarounds for circular imports, the code was all jumbled so modularization at this point was almost impossible, barely managed it
# Way better looking imports
from imports import *
from bronxbot import bot, BronxBot, additional_stats_update, reset_daily_stats, stats_tracker, config, dev # gotta import separate classes outside of imports.py to avoid circular imports
from cogInfo import CogLoader
from botEvents.onReady import *
from botEvents.onCommand import *
from botEvents.onMessage import *
from misc._commands import setup
from misc.blacklist import blacklist_check
setup(bot)
if os.path.exists("data/restart_info.json"):
try:
with open("data/restart_info.json", "r") as f:
restart_info = json.load(f)
bot.restart_channel = restart_info["channel_id"]
bot.restart_message = restart_info["message_id"]
os.remove("data/restart_info.json")
except Exception as e:
print(f"Failed to load restart info: {e}")
if __name__ == "__main__":
import platform
# Print startup info
logging.info(f"Python version: {platform.python_version()}")
logging.info(f"Discord.py version: {discord.__version__}")
logging.info(f"Starting BronxBot with {bot.shard_count} shards")
# Run the Discord bot
if dev:
logging.info("Running in development mode")
system("clear" if os.name == "posix" else "cls")
if os.name == "posix":
sys.stdout.write("\x1b]2;BronxBot (DEV)\x07")
bot.run(config['DEV_TOKEN'], log_handler=None) # Disable default discord.py logging
else:
try:
system("clear" if os.name == "posix" else "cls")
if os.name == "posix":
sys.stdout.write("\x1b]2;BronxBot\x07")
bot.run(config['TOKEN'], log_handler=None) # Disable default discord.py logging
except Exception as e:
logging.error(f"Failed to start the bot: {e}")
traceback.print_exc()