From 4e632276c227edcf7fcf54aa6fae54fbbc627286 Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Fri, 15 Nov 2024 00:50:55 +0000 Subject: [PATCH] fix: Resolve command registration issues - Separate command handling into VideoArchiverCommands - Update command registration in __init__.py - Remove duplicate command registration --- videoarchiver/__init__.py | 8 ++++---- videoarchiver/video_archiver.py | 10 +--------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/videoarchiver/__init__.py b/videoarchiver/__init__.py index b40517f..1a453fb 100644 --- a/videoarchiver/__init__.py +++ b/videoarchiver/__init__.py @@ -1,12 +1,12 @@ """VideoArchiver cog for Red-DiscordBot""" from redbot.core.bot import Red from .video_archiver import VideoArchiver +from .commands import VideoArchiverCommands async def setup(bot: Red) -> None: """Load VideoArchiver.""" cog = VideoArchiver(bot) await bot.add_cog(cog) - # Sync commands with Discord - if not hasattr(bot, "tree"): - return - await bot.tree.sync() + # Add commands from VideoArchiverCommands + commands_cog = VideoArchiverCommands(bot, cog.config_manager, cog.update_checker, cog.processor) + await bot.add_cog(commands_cog) diff --git a/videoarchiver/video_archiver.py b/videoarchiver/video_archiver.py index f003a34..88f17a9 100644 --- a/videoarchiver/video_archiver.py +++ b/videoarchiver/video_archiver.py @@ -2,7 +2,7 @@ from __future__ import annotations import discord -from redbot.core import commands, Config, data_manager, app_commands +from redbot.core import commands, Config, data_manager from pathlib import Path import logging import asyncio @@ -123,10 +123,6 @@ class VideoArchiver(commands.Cog): # Wait for initialization to complete await asyncio.wait_for(self.ready.wait(), timeout=30) - # Add commands to the bot - for command in self.commands_handler.videoarchiver.commands: - self.bot.tree.add_command(command) - except asyncio.TimeoutError: await self._cleanup() raise ProcessingError("Cog initialization timed out") @@ -136,10 +132,6 @@ class VideoArchiver(commands.Cog): async def cog_unload(self) -> None: """Clean up when cog is unloaded""" - # Remove commands from the bot - for command in self.commands_handler.videoarchiver.commands: - self.bot.tree.remove_command(command.name) - await self._cleanup() async def _cleanup(self) -> None: