fix: add chat snapshot delivery success/failure logging
This commit is contained in:
8
bot.py
8
bot.py
@@ -941,6 +941,7 @@ class GravityBot(commands.Bot):
|
||||
))
|
||||
try:
|
||||
await channel.send(embed=embed, files=discord_files)
|
||||
logger.info(f"[SNAPSHOT] Sent to #{channel.name} (file, {len(content)} chars)")
|
||||
except discord.NotFound:
|
||||
logger.warning(f"Channel deleted for {project}, re-creating...")
|
||||
self.project_channels.pop(project, None)
|
||||
@@ -961,6 +962,9 @@ class GravityBot(commands.Bot):
|
||||
filename="chat_message.md",
|
||||
))
|
||||
await channel.send(embed=embed, files=discord_files2)
|
||||
logger.info(f"[SNAPSHOT] Sent to #{channel.name} after re-create (file, {len(content)} chars)")
|
||||
except Exception as e:
|
||||
logger.error(f"[SNAPSHOT] Discord send failed for {project}: {e}")
|
||||
else:
|
||||
# Short content → inline embed (original)
|
||||
embed = discord.Embed(
|
||||
@@ -974,12 +978,16 @@ class GravityBot(commands.Bot):
|
||||
embed=embed,
|
||||
files=discord_files if discord_files else discord.utils.MISSING,
|
||||
)
|
||||
logger.info(f"[SNAPSHOT] Sent to #{channel.name} (inline, {len(content)} chars)")
|
||||
except discord.NotFound:
|
||||
logger.warning(f"Channel deleted for {project}, re-creating...")
|
||||
self.project_channels.pop(project, None)
|
||||
channel = await self._get_channel(project)
|
||||
if channel:
|
||||
await channel.send(embed=embed)
|
||||
logger.info(f"[SNAPSHOT] Sent to #{channel.name} after re-create (inline)")
|
||||
except Exception as e:
|
||||
logger.error(f"[SNAPSHOT] Discord send failed for {project}: {e}")
|
||||
|
||||
f.unlink() # Cleanup
|
||||
except (json.JSONDecodeError, OSError) as e:
|
||||
|
||||
Reference in New Issue
Block a user