File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3737# Initialize cog manager
3838cogs_manager = CogsManager (bot )
3939
40+ # Flag if bot startup is complete
41+ bot_startup_complete = False
42+
4043
4144@bot .event
4245async def on_ready ():
4346 """
4447 Handle bot ready event.
4548 """
46- console_logger .info (f"Logged in as { bot .user } (ID: { bot .user .id } )" )
47-
48- # Initialize DB and ticket counters
49- await init_db ()
50- bot .loop .create_task (initialize_ticket_counter_table ())
51-
52- # Load all cogs
53- await cogs_manager .load_all_cogs ()
54-
55- # Log readiness and available commands
56- console_logger .info (f"Bot is ready with { len (bot .tree .get_commands ())} command(s) loaded:" )
57- for cmd in bot .tree .get_commands ():
58- console_logger .info (f"Command loaded: { cmd .name } " )
49+ # Run logic only if bot startup is incomplete
50+ global bot_startup_complete
51+ if not bot_startup_complete :
52+ console_logger .info (f"Logged in as { bot .user } (ID: { bot .user .id } )" )
53+
54+ # Initialize DB and ticket counters
55+ await init_db ()
56+ bot .loop .create_task (initialize_ticket_counter_table ())
57+
58+ # Load all cogs
59+ await cogs_manager .load_all_cogs ()
60+
61+ # Log readiness and available commands
62+ console_logger .info (f"Bot is ready with { len (bot .tree .get_commands ())} command(s) loaded:" )
63+ for cmd in bot .tree .get_commands ():
64+ console_logger .info (f"Command loaded: { cmd .name } " )
65+
66+ bot_startup_complete = True
67+ else :
68+ console_logger .info ("Reconnected to Discord." )
5969
6070
6171# Run the bot using the token from .env
You can’t perform that action at this time.
0 commit comments