"""Discord 채널/스레드 메시지 전송 도구.""" from __future__ import annotations import asyncio import logging import os from typing import Any from agent.utils.discord_client import get_discord_client logger = logging.getLogger(__name__) def discord_reply(message: str) -> dict[str, Any]: if not message.strip(): return {"success": False, "error": "빈 메시지는 전송할 수 없습니다."} channel_id = os.environ.get("DISCORD_CHANNEL_ID", "") if not channel_id: return {"success": False, "error": "DISCORD_CHANNEL_ID가 설정되지 않았습니다."} client = get_discord_client() try: result = asyncio.run( client.send_message(channel_id=channel_id, content=message) ) logger.info("Sent Discord message to channel %s", channel_id) return {"success": True, "message_id": result.get("id")} except Exception as e: logger.exception("Failed to send Discord message") return {"success": False, "error": str(e)}