mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 02:41:06 -05:00
fix: Simplify cog initialization - Let Red handle command syncing - Remove manual sync operations - Clean up __init__.py files
This commit is contained in:
@@ -5,26 +5,9 @@ from .birthday import Birthday
|
|||||||
async def setup(bot: Red) -> None:
|
async def setup(bot: Red) -> None:
|
||||||
"""Load Birthday cog."""
|
"""Load Birthday cog."""
|
||||||
cog = Birthday(bot)
|
cog = Birthday(bot)
|
||||||
# Add cog first
|
|
||||||
await bot.add_cog(cog)
|
await bot.add_cog(cog)
|
||||||
# Then sync commands after cog is loaded
|
|
||||||
if hasattr(bot, "tree"):
|
|
||||||
try:
|
|
||||||
# Only sync guild commands to avoid rate limits
|
|
||||||
await bot.tree.sync(guild=None)
|
|
||||||
except Exception as e:
|
|
||||||
# Log error but don't fail cog load
|
|
||||||
bot.log.error(f"Failed to sync commands: {str(e)}")
|
|
||||||
|
|
||||||
async def teardown(bot: Red) -> None:
|
async def teardown(bot: Red) -> None:
|
||||||
"""Clean up when unloading."""
|
"""Clean up when unloading."""
|
||||||
if hasattr(bot, "tree"):
|
# Let Red handle command cleanup
|
||||||
try:
|
pass
|
||||||
# Remove all commands from this cog
|
|
||||||
for command in bot.tree.get_commands():
|
|
||||||
bot.tree.remove_command(command.name)
|
|
||||||
# Sync to remove commands from Discord
|
|
||||||
await bot.tree.sync(guild=None)
|
|
||||||
except Exception as e:
|
|
||||||
# Log error but don't fail cog unload
|
|
||||||
bot.log.error(f"Failed to cleanup commands: {str(e)}")
|
|
||||||
|
|||||||
@@ -5,26 +5,9 @@ from .overseerr import Overseerr
|
|||||||
async def setup(bot: Red) -> None:
|
async def setup(bot: Red) -> None:
|
||||||
"""Load Overseerr cog."""
|
"""Load Overseerr cog."""
|
||||||
cog = Overseerr(bot)
|
cog = Overseerr(bot)
|
||||||
# Add cog first
|
|
||||||
await bot.add_cog(cog)
|
await bot.add_cog(cog)
|
||||||
# Then sync commands after cog is loaded
|
|
||||||
if hasattr(bot, "tree"):
|
|
||||||
try:
|
|
||||||
# Only sync guild commands to avoid rate limits
|
|
||||||
await bot.tree.sync(guild=None)
|
|
||||||
except Exception as e:
|
|
||||||
# Log error but don't fail cog load
|
|
||||||
bot.log.error(f"Failed to sync commands: {str(e)}")
|
|
||||||
|
|
||||||
async def teardown(bot: Red) -> None:
|
async def teardown(bot: Red) -> None:
|
||||||
"""Clean up when unloading."""
|
"""Clean up when unloading."""
|
||||||
if hasattr(bot, "tree"):
|
# Let Red handle command cleanup
|
||||||
try:
|
pass
|
||||||
# Remove all commands from this cog
|
|
||||||
for command in bot.tree.get_commands():
|
|
||||||
bot.tree.remove_command(command.name)
|
|
||||||
# Sync to remove commands from Discord
|
|
||||||
await bot.tree.sync(guild=None)
|
|
||||||
except Exception as e:
|
|
||||||
# Log error but don't fail cog unload
|
|
||||||
bot.log.error(f"Failed to cleanup commands: {str(e)}")
|
|
||||||
|
|||||||
@@ -5,26 +5,9 @@ from .video_archiver import VideoArchiver
|
|||||||
async def setup(bot: Red) -> None:
|
async def setup(bot: Red) -> None:
|
||||||
"""Load VideoArchiver."""
|
"""Load VideoArchiver."""
|
||||||
cog = VideoArchiver(bot)
|
cog = VideoArchiver(bot)
|
||||||
# Add cog first
|
|
||||||
await bot.add_cog(cog)
|
await bot.add_cog(cog)
|
||||||
# Then sync commands after cog is loaded
|
|
||||||
if hasattr(bot, "tree"):
|
|
||||||
try:
|
|
||||||
# Only sync guild commands to avoid rate limits
|
|
||||||
await bot.tree.sync(guild=None)
|
|
||||||
except Exception as e:
|
|
||||||
# Log error but don't fail cog load
|
|
||||||
bot.log.error(f"Failed to sync commands: {str(e)}")
|
|
||||||
|
|
||||||
async def teardown(bot: Red) -> None:
|
async def teardown(bot: Red) -> None:
|
||||||
"""Clean up when unloading."""
|
"""Clean up when unloading."""
|
||||||
if hasattr(bot, "tree"):
|
# Let Red handle command cleanup
|
||||||
try:
|
pass
|
||||||
# Remove all commands from this cog
|
|
||||||
for command in bot.tree.get_commands():
|
|
||||||
bot.tree.remove_command(command.name)
|
|
||||||
# Sync to remove commands from Discord
|
|
||||||
await bot.tree.sync(guild=None)
|
|
||||||
except Exception as e:
|
|
||||||
# Log error but don't fail cog unload
|
|
||||||
bot.log.error(f"Failed to cleanup commands: {str(e)}")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user