fix: add channel failure logging to diagnose Discord notification delivery issue
This commit is contained in:
18
bot.py
18
bot.py
@@ -365,6 +365,10 @@ class GravityBot(commands.Bot):
|
||||
if project_name in self.project_channels:
|
||||
return self.project_channels[project_name]
|
||||
|
||||
if not self.session_category:
|
||||
logger.error(f"[CHANNEL] session_category is None — cannot get channel for project={project_name}")
|
||||
return None
|
||||
|
||||
channel_name = self._make_channel_name(project_name)
|
||||
|
||||
# 1. Check guild channel cache (NO API call — instant)
|
||||
@@ -405,6 +409,9 @@ class GravityBot(commands.Bot):
|
||||
except discord.errors.Forbidden:
|
||||
logger.error(f"No permission to create channel: {channel_name}")
|
||||
return None
|
||||
except Exception as e:
|
||||
logger.error(f"[CHANNEL] Failed to create channel #{channel_name}: {e}")
|
||||
return None
|
||||
|
||||
def _resolve_project(self, conversation_id: str) -> str:
|
||||
"""Get project name for a conversation. Falls back to default."""
|
||||
@@ -619,6 +626,7 @@ class GravityBot(commands.Bot):
|
||||
# Show compact auto-approved embed in Discord
|
||||
channel = await self._get_channel(project)
|
||||
if channel:
|
||||
try:
|
||||
embed = discord.Embed(
|
||||
title="🤖 자동 승인됨",
|
||||
description=f"```\n{req.command[:500]}\n```",
|
||||
@@ -626,6 +634,10 @@ class GravityBot(commands.Bot):
|
||||
)
|
||||
embed.set_footer(text=f"auto-approve | {req.request_id[:12]}")
|
||||
await channel.send(embed=embed)
|
||||
except Exception as e:
|
||||
logger.error(f"[AUTO-APPROVE] Discord send failed for {project}: {e}")
|
||||
else:
|
||||
logger.warning(f"[AUTO-APPROVE] No Discord channel for project={project} — notification skipped")
|
||||
logger.info(f"Auto-approved: {req.request_id[:12]} project={project} btn_idx={approve_btn_index}")
|
||||
phase1_processed += 1
|
||||
continue
|
||||
@@ -655,6 +667,8 @@ class GravityBot(commands.Bot):
|
||||
self._sent_commands[req.request_id] = req.command
|
||||
await self._send_approval_request(channel, req)
|
||||
phase1_processed += 1
|
||||
else:
|
||||
logger.warning(f"[APPROVAL] No Discord channel for project={project} — approval request skipped (rid={req.request_id[:12]})")
|
||||
|
||||
# ── Single-pass: handle auto_resolved, expired, and MERGE in one glob ──
|
||||
phase2_processed = 0
|
||||
@@ -894,7 +908,9 @@ class GravityBot(commands.Bot):
|
||||
|
||||
if content or attached_files:
|
||||
channel = await self._get_channel(project)
|
||||
if channel:
|
||||
if not channel:
|
||||
logger.warning(f"[SNAPSHOT] No Discord channel for project={project} — snapshot skipped (len={len(content)})")
|
||||
elif channel:
|
||||
import io
|
||||
|
||||
# ── Send attached files (from Extension's writeChatSnapshotWithFiles) ──
|
||||
|
||||
Reference in New Issue
Block a user