mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 10:51:05 -05:00
fix
This commit is contained in:
@@ -106,38 +106,33 @@ class VideoArchiver(GroupCog):
|
|||||||
async def enable_database(self, ctx: Context):
|
async def enable_database(self, ctx: Context):
|
||||||
"""Enable the video archive database."""
|
"""Enable the video archive database."""
|
||||||
try:
|
try:
|
||||||
# First check if database is already enabled
|
# Check if database is already enabled
|
||||||
try:
|
|
||||||
current_setting = await self.config_manager.get_setting(
|
current_setting = await self.config_manager.get_setting(
|
||||||
ctx.guild.id, "use_database"
|
ctx.guild.id, "use_database"
|
||||||
)
|
)
|
||||||
if current_setting:
|
if current_setting:
|
||||||
await ctx.send("The video archive database is already enabled.")
|
await ctx.send("The video archive database is already enabled.")
|
||||||
return
|
return
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Failed to get setting use_database: {e}")
|
|
||||||
# If setting doesn't exist, we'll create it
|
|
||||||
await self.config_manager.update_setting(ctx.guild.id, "use_database", False)
|
|
||||||
|
|
||||||
# Initialize database if it's being enabled
|
# Initialize database
|
||||||
try:
|
|
||||||
self.db = VideoArchiveDB(self.data_path)
|
self.db = VideoArchiveDB(self.data_path)
|
||||||
|
|
||||||
# Update processor with database
|
# Update processor with database
|
||||||
if self.processor:
|
if self.processor:
|
||||||
self.processor.db = self.db
|
self.processor.db = self.db
|
||||||
if self.processor.queue_handler:
|
if self.processor.queue_handler:
|
||||||
self.processor.queue_handler.db = self.db
|
self.processor.queue_handler.db = self.db
|
||||||
|
|
||||||
|
# Update setting
|
||||||
await self.config_manager.update_setting(ctx.guild.id, "use_database", True)
|
await self.config_manager.update_setting(ctx.guild.id, "use_database", True)
|
||||||
|
|
||||||
|
# Send success message
|
||||||
await ctx.send("Video archive database has been enabled.")
|
await ctx.send("Video archive database has been enabled.")
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Error initializing database: {e}")
|
|
||||||
await ctx.send("An error occurred while initializing the database.")
|
|
||||||
return
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error enabling database: {e}")
|
logger.error(f"Error enabling database: {e}")
|
||||||
await ctx.send("An error occurred while enabling the database.")
|
# Send single error message
|
||||||
|
await ctx.send("An error occurred while enabling the database. Please check the logs for details.")
|
||||||
|
|
||||||
@archivedb.command(name="disable")
|
@archivedb.command(name="disable")
|
||||||
@guild_only()
|
@guild_only()
|
||||||
|
|||||||
Reference in New Issue
Block a user