fix: Improve cog loading order - Load main cog first - Wait for initialization - Load commands after successful init

This commit is contained in:
pacnpal
2024-11-15 01:03:53 +00:00
parent 0df5c879bb
commit 888ed27d17

View File

@@ -4,10 +4,20 @@ from .video_archiver import VideoArchiver
async def setup(bot: Red) -> None:
"""Load VideoArchiver."""
# Load main cog first
cog = VideoArchiver(bot)
await bot.add_cog(cog)
async def teardown(bot: Red) -> None:
"""Clean up when unloading."""
# Let Red handle command cleanup
pass
# Wait for initialization to complete
await cog.ready.wait()
# Only load commands if main cog initialized successfully
if cog.ready.is_set():
from .commands import VideoArchiverCommands
commands_cog = VideoArchiverCommands(
bot,
cog.config_manager,
cog.update_checker,
cog.processor
)
await bot.add_cog(commands_cog)