mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 02:41:06 -05:00
base.py: Streamlined to core cog functionality and lifecycle management initialization.py: Centralized initialization logic error_handler.py: Unified error handling response_handler.py: Consistent response handling Command Organization: commands/archiver_commands.py: Core archiver functionality commands/database_commands.py: Database operations commands/settings_commands.py: Settings management All commands properly integrated with the cog using setup functions Improved Architecture: Consistent command registration pattern Better separation of concerns Maintained all original functionality Enhanced error handling and response management Proper command integration with the cog structure
83 lines
2.9 KiB
Python
83 lines
2.9 KiB
Python
"""Module for core archiver commands"""
|
|
|
|
import discord
|
|
from redbot.core.commands import Context, hybrid_group, guild_only, checks
|
|
from discord import app_commands
|
|
import logging
|
|
from ..response_handler import handle_response
|
|
|
|
logger = logging.getLogger("VideoArchiver")
|
|
|
|
def setup_archiver_commands(cog):
|
|
"""Set up archiver commands for the cog"""
|
|
|
|
@cog.hybrid_group(name="archiver", fallback="help")
|
|
@guild_only()
|
|
async def archiver(ctx: Context):
|
|
"""Manage video archiver settings."""
|
|
if ctx.invoked_subcommand is None:
|
|
await handle_response(
|
|
ctx, "Use `/help archiver` for a list of commands."
|
|
)
|
|
|
|
@archiver.command(name="enable")
|
|
@guild_only()
|
|
@checks.admin_or_permissions(administrator=True)
|
|
async def enable_archiver(ctx: Context):
|
|
"""Enable video archiving in this server."""
|
|
try:
|
|
current_setting = await cog.config_manager.get_setting(
|
|
ctx.guild.id, "enabled"
|
|
)
|
|
if current_setting:
|
|
await handle_response(ctx, "Video archiving is already enabled.")
|
|
return
|
|
|
|
await cog.config_manager.update_setting(ctx.guild.id, "enabled", True)
|
|
await handle_response(ctx, "Video archiving has been enabled.")
|
|
|
|
except Exception as e:
|
|
logger.error(f"Error enabling archiver: {e}")
|
|
await handle_response(
|
|
ctx, "An error occurred while enabling video archiving."
|
|
)
|
|
|
|
@archiver.command(name="disable")
|
|
@guild_only()
|
|
@checks.admin_or_permissions(administrator=True)
|
|
async def disable_archiver(ctx: Context):
|
|
"""Disable video archiving in this server."""
|
|
try:
|
|
current_setting = await cog.config_manager.get_setting(
|
|
ctx.guild.id, "enabled"
|
|
)
|
|
if not current_setting:
|
|
await handle_response(ctx, "Video archiving is already disabled.")
|
|
return
|
|
|
|
await cog.config_manager.update_setting(ctx.guild.id, "enabled", False)
|
|
await handle_response(ctx, "Video archiving has been disabled.")
|
|
|
|
except Exception as e:
|
|
logger.error(f"Error disabling archiver: {e}")
|
|
await handle_response(
|
|
ctx, "An error occurred while disabling video archiving."
|
|
)
|
|
|
|
@archiver.command(name="queue")
|
|
@guild_only()
|
|
async def show_queue(ctx: Context):
|
|
"""Show the current video processing queue."""
|
|
# Defer the response immediately for slash commands
|
|
if hasattr(ctx, "interaction") and ctx.interaction:
|
|
await ctx.defer()
|
|
await cog.processor.show_queue_details(ctx)
|
|
|
|
# Store commands in cog for access
|
|
cog.archiver = archiver
|
|
cog.enable_archiver = enable_archiver
|
|
cog.disable_archiver = disable_archiver
|
|
cog.show_queue = show_queue
|
|
|
|
return archiver
|