mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 10:51:05 -05:00
fix: Resolve command registration issues - Separate command handling into VideoArchiverCommands - Update command registration in __init__.py - Remove duplicate command registration
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
"""VideoArchiver cog for Red-DiscordBot"""
|
"""VideoArchiver cog for Red-DiscordBot"""
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
from .video_archiver import VideoArchiver
|
from .video_archiver import VideoArchiver
|
||||||
|
from .commands import VideoArchiverCommands
|
||||||
|
|
||||||
async def setup(bot: Red) -> None:
|
async def setup(bot: Red) -> None:
|
||||||
"""Load VideoArchiver."""
|
"""Load VideoArchiver."""
|
||||||
cog = VideoArchiver(bot)
|
cog = VideoArchiver(bot)
|
||||||
await bot.add_cog(cog)
|
await bot.add_cog(cog)
|
||||||
# Sync commands with Discord
|
# Add commands from VideoArchiverCommands
|
||||||
if not hasattr(bot, "tree"):
|
commands_cog = VideoArchiverCommands(bot, cog.config_manager, cog.update_checker, cog.processor)
|
||||||
return
|
await bot.add_cog(commands_cog)
|
||||||
await bot.tree.sync()
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from redbot.core import commands, Config, data_manager, app_commands
|
from redbot.core import commands, Config, data_manager
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import logging
|
import logging
|
||||||
import asyncio
|
import asyncio
|
||||||
@@ -123,10 +123,6 @@ class VideoArchiver(commands.Cog):
|
|||||||
# Wait for initialization to complete
|
# Wait for initialization to complete
|
||||||
await asyncio.wait_for(self.ready.wait(), timeout=30)
|
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:
|
except asyncio.TimeoutError:
|
||||||
await self._cleanup()
|
await self._cleanup()
|
||||||
raise ProcessingError("Cog initialization timed out")
|
raise ProcessingError("Cog initialization timed out")
|
||||||
@@ -136,10 +132,6 @@ class VideoArchiver(commands.Cog):
|
|||||||
|
|
||||||
async def cog_unload(self) -> None:
|
async def cog_unload(self) -> None:
|
||||||
"""Clean up when cog is unloaded"""
|
"""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()
|
await self._cleanup()
|
||||||
|
|
||||||
async def _cleanup(self) -> None:
|
async def _cleanup(self) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user