fix(pr): Address PR feedback Round 3 (#5)
- Fix Config attribute access paths - Secure permission decorator against DMs - Fix webhook JSON serialization
This commit is contained in:
+2
-2
@@ -24,7 +24,7 @@ def main():
|
||||
logger.critical(f"Failed to load configuration: {e}")
|
||||
return
|
||||
|
||||
if not config.discord_token:
|
||||
if not config.discord.token:
|
||||
logger.critical("Discord token not found! Set DISCORDBOT_DISCORD_TOKEN env var or config.yaml")
|
||||
return
|
||||
|
||||
@@ -32,7 +32,7 @@ def main():
|
||||
bot = ComfyUIBot(config)
|
||||
|
||||
try:
|
||||
bot.run(config.discord_token)
|
||||
bot.run(config.discord.token)
|
||||
except KeyboardInterrupt:
|
||||
logger.info("Bot stopped by user.")
|
||||
except Exception as e:
|
||||
|
||||
+3
-3
@@ -31,12 +31,12 @@ class ComfyUIBot(commands.Bot):
|
||||
self.config = config
|
||||
|
||||
# Database
|
||||
self.repository = Repository(config.database_url)
|
||||
self.repository = Repository(config.database.url)
|
||||
|
||||
|
||||
# ComfyUI Clients
|
||||
self.comfy_client = ComfyUIClient(base_url=config.comfyui_url)
|
||||
self.comfy_ws = ComfyUIWebSocket(base_url=config.comfyui_url)
|
||||
self.comfy_client = ComfyUIClient(base_url=config.comfyui.url)
|
||||
self.comfy_ws = ComfyUIWebSocket(base_url=config.comfyui.url)
|
||||
|
||||
# Services
|
||||
from .services.delivery import DeliveryService
|
||||
|
||||
@@ -74,8 +74,9 @@ class PermissionService:
|
||||
def require_permission(level: str):
|
||||
async def predicate(interaction: discord.Interaction):
|
||||
if not interaction.guild:
|
||||
return True # DMs are always allowed/handled differently? Or restrict?
|
||||
# For now, let's assume commands needing permissions are guild-only.
|
||||
await interaction.response.send_message("⛔ This command cannot be used in DMs.", ephemeral=True)
|
||||
return False
|
||||
|
||||
|
||||
# We need to access the bot instance to get the permission service
|
||||
bot = interaction.client
|
||||
|
||||
@@ -11,6 +11,7 @@ import logging
|
||||
from io import BytesIO
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
import json
|
||||
import requests
|
||||
|
||||
# Get logger for this module
|
||||
@@ -220,7 +221,7 @@ class DiscordWebhookClient:
|
||||
if files:
|
||||
response = requests.post(
|
||||
self.webhook_url,
|
||||
data={"payload_json": str(data)} if data else None,
|
||||
data={"payload_json": json.dumps(data)} if data else None,
|
||||
files=files,
|
||||
timeout=60
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user