jackwener / jackwener/discord-cli

Attachment URLs are discarded when parsing messages

Open Beginner friendly
#2 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
130
Forks
29
PR merge metrics
No merged PRs in 30d

Description

## Summary

When parsing a Discord message, `_parse_message` keeps only the attachment **filename** and discards the CDN **url** that the API returns:

```python
# src/discord_cli/client.py
for att in msg.get("attachments", []):
content_parts.append(f"[attachment: {att.get('filename', 'file')}]")
```

So a message that contains an image or file is stored as a bare placeholder:

```
[attachment: screenshot.png]
```

## Impact

The actual file is unreachable from stored content. `export`, `search`, and `recent` all show the placeholder with no URL, so there is no way to fetch the image/file an agent (or user) is looking at. For a local-first, agent-friendly tool this is the difference between "an image was posted" and "here is the image."

## Steps to reproduce

1. Fetch a channel that has an image attachment: `discord dc history -n 30`
2. `discord export -f text`
3. Observe `[attachment: foo.png]` with no URL.

## Expected

The attachment URL is preserved so the file can be retrieved, e.g.:

```
[attachment: screenshot.png](https://cdn.discordapp.com/attachments/.../screenshot.png?ex=...)
```

Fix proposed in #1 (preserve `url`, fall back to `proxy_url`, then to the bare placeholder).

Contributor guide

Open the contributing guide

Research direction

Start in src/discord_cli/client.py at _parse_message and inspect how attachment fields are added to content. Reproduce with `discord dc history -n 30` and `discord export -f text`; done means stored attachment text preserves the URL, falls back to proxy_url, and retains the bare placeholder when neither is available.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.