From 97e0d9c2791da0bb4a5d69ef6029d6ffb1e89be1 Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Fri, 15 Nov 2024 22:17:30 +0000 Subject: [PATCH] re-structure --- videoarchiver/__init__.py | 27 +++------------------------ videoarchiver/commands.py | 6 +++--- videoarchiver/video_archiver.py | 7 ------- 3 files changed, 6 insertions(+), 34 deletions(-) delete mode 100644 videoarchiver/video_archiver.py diff --git a/videoarchiver/__init__.py b/videoarchiver/__init__.py index d80b2cd..9c230c1 100644 --- a/videoarchiver/__init__.py +++ b/videoarchiver/__init__.py @@ -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: diff --git a/videoarchiver/commands.py b/videoarchiver/commands.py index 17287ce..91542fb 100644 --- a/videoarchiver/commands.py +++ b/videoarchiver/commands.py @@ -1,4 +1,4 @@ -"""Re-export commands from core.commands""" -from .core.commands import VideoArchiverCommands +"""Re-export commands from core.base""" +from .core.base import VideoArchiver -__all__ = ['VideoArchiverCommands'] +__all__ = ['VideoArchiver'] diff --git a/videoarchiver/video_archiver.py b/videoarchiver/video_archiver.py deleted file mode 100644 index 3622b51..0000000 --- a/videoarchiver/video_archiver.py +++ /dev/null @@ -1,7 +0,0 @@ -"""VideoArchiver cog for Red-DiscordBot""" - -from .core import VideoArchiver - -def setup(bot): - """Load VideoArchiver cog.""" - bot.add_cog(VideoArchiver(bot))