re-structure

This commit is contained in:
pacnpal
2024-11-15 22:17:30 +00:00
parent 5fedd97b61
commit 97e0d9c279
3 changed files with 6 additions and 34 deletions

View File

@@ -2,7 +2,7 @@
from redbot.core.bot import Red
import asyncio
import logging
from .video_archiver import VideoArchiver
from .core.base import VideoArchiver
from .exceptions import ProcessingError
logger = logging.getLogger("VideoArchiver")
@@ -10,7 +10,7 @@ logger = logging.getLogger("VideoArchiver")
async def setup(bot: Red) -> None:
"""Load VideoArchiver."""
try:
# Load main cog first
# Load main cog
cog = VideoArchiver(bot)
await bot.add_cog(cog)
@@ -22,23 +22,7 @@ async def setup(bot: Red) -> None:
await bot.remove_cog(cog.__class__.__name__)
raise ProcessingError("Initialization timed out")
# Only load commands if main cog initialized successfully
if cog.ready.is_set():
try:
from .commands import VideoArchiverCommands
commands_cog = VideoArchiverCommands(
bot,
cog.config_manager,
cog.update_checker,
cog.processor
)
await bot.add_cog(commands_cog)
except Exception as e:
logger.error(f"Failed to load commands cog: {str(e)}")
# Clean up main cog if commands fail to load
await bot.remove_cog(cog.__class__.__name__)
raise
else:
if not cog.ready.is_set():
logger.error("VideoArchiver failed to initialize")
await bot.remove_cog(cog.__class__.__name__)
raise ProcessingError("Initialization failed")
@@ -50,11 +34,6 @@ async def setup(bot: Red) -> None:
async def teardown(bot: Red) -> None:
"""Clean up when unloading."""
try:
# Remove commands cog first
if "VideoArchiverCommands" in bot.cogs:
await bot.remove_cog("VideoArchiverCommands")
# Then remove main cog
if "VideoArchiver" in bot.cogs:
await bot.remove_cog("VideoArchiver")
except Exception as e: