Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions gateway/platforms/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -4167,6 +4167,17 @@ async def _handle_message(self, message: DiscordMessage) -> None:
raw_content = message.content.strip()
normalized_content = raw_content
mention_prefix = False

snapshot_attachments = []
if hasattr(message, "message_snapshots") and message.message_snapshots:
Comment on lines +4171 to +4172
snapshot_text_parts = []
for snap in message.message_snapshots:
if getattr(snap, "content", None):
snapshot_text_parts.append(snap.content.strip())
snapshot_attachments.extend(getattr(snap, "attachments", []) or [])
Comment on lines +4174 to +4177
if snapshot_text_parts and not raw_content:
raw_content = "\n".join(snapshot_text_parts)
Comment on lines +4178 to +4179
normalized_content = raw_content
if self._client.user and self._client.user in message.mentions:
mention_prefix = True
normalized_content = normalized_content.replace(f"<@{self._client.user.id}>", "").strip()
Expand Down Expand Up @@ -4235,13 +4246,15 @@ async def _handle_message(self, message: DiscordMessage) -> None:
auto_threaded_channel = thread
self._threads.mark(thread_id)

all_attachments = list(message.attachments) + snapshot_attachments

# Determine message type
msg_type = MessageType.TEXT
if normalized_content.startswith("/"):
msg_type = MessageType.COMMAND
elif message.attachments:
elif all_attachments:
# Check attachment types
for att in message.attachments:
for att in all_attachments:
if att.content_type:
if att.content_type.startswith("image/"):
msg_type = MessageType.PHOTO
Expand Down Expand Up @@ -4300,7 +4313,7 @@ async def _handle_message(self, message: DiscordMessage) -> None:
media_urls = []
media_types = []
pending_text_injection: Optional[str] = None
for att in message.attachments:
for att in all_attachments:
content_type = att.content_type or "unknown"
if content_type.startswith("image/"):
try:
Expand Down