From 2,782 Discord Messages to a Docs Site in Three Languages
A read-only Discord bot, a Python export of 2,782 messages, answers checked against the source code, and a Starlight docs site in English, German, Spanish.
TalePainter is a world generation tool for Hytale. It's a GPL fork of WorldPainter, and the source is public on GitHub. The problem was never the tool. Every answer to "how do I install this", "why does my world not load" or "how much RAM does it need" was somewhere in a Discord server. If you didn't scroll for half an hour, you asked again, and someone answered again.
So I pulled the whole history out, sorted it into questions and answers, checked the answers against the code and built a proper docs site. It's live at docs.talepainter.net in English, German and Spanish. All of it happened on one day, and most of that day was reading.
TL;DR: Make a private Discord bot with the Message Content intent and only two permissions: View Channels and Read Message History. Export every channel and thread to JSON with a small Python script, file names with the channel ID. Turn the export into a question to answer list, check every fact against the source code, then write the docs from that list only. Build with Astro Starlight, deploy the static output with tar and ssh. Staff chat and moderation logs never go into public docs.
Step 1: a bot that can only read
It's a private app in the Discord developer portal, invited to exactly one server.
- Message Content intent on. Without it, the API gives you messages with empty
contentfor most of them. That's useless for an export. - Permissions: View Channels (1024) and Read Message History (65536). Together that's the permission integer
66560. No Send Messages, no Manage anything.
The token lives in a text file next to the script, and that file is in .gitignore. Same with the export folder.
bot-token.txt
export/
Step 2: export everything to JSON
The script uses plain urllib, no Discord library. It never sends anything, it only does GET requests. The core is the message pagination: Discord gives you 100 messages per call, and you walk backwards with before=.
def messages(channel_id):
out, before = [], None
while True:
q = f"/channels/{channel_id}/messages?limit=100" + (f"&before={before}" if before else "")
batch = get(q)
if not batch:
break
out.extend(batch)
before = batch[-1]["id"]
if len(batch) < 100:
break
out.reverse() # oldest first, easier to read
return out
get() handles two things. On HTTP 429 it sleeps for the retry_after value Discord sends back and tries again. On 403 or 404 it returns nothing, because a bot that can't see a channel should just skip it.
Channels alone are not enough. Forum channels have no messages of their own, everything is in threads. So per channel the script also collects:
active = get(f"/guilds/{guild_id}/threads/active")["threads"]
# plus, per channel, paged:
get(f"/channels/{channel_id}/threads/archived/public?limit=100")
Archived threads matter most. A solved support ticket gets archived, and that's exactly the answer you want.
Result: 60 files, 2,782 messages. The support ticket forum was the biggest part, followed by bug reports, general and two developer threads.
Gotcha: fancy Unicode channel names
The channel names on that server use those decorative "script" Unicode letters and emojis. They look nice in Discord. They are a pain as file names. Lowercasing doesn't turn them into normal letters, emoji-only parts get stripped, and you can't rely on two channels ending up with different names.
The fix is boring: the channel ID goes into every file name. The name is only decoration.
def slug(s):
return (re.sub(r"[^\w-]+", "-", s.lower()).strip("-_") or "ch")[:80]
path = gdir / f"{slug(c['name'])}-{c['id']}.json"
Threads get their own file in a folder named after the parent channel, also with both IDs. Now nothing collides and I can always find the channel again.
Gotcha: the Windows console and UTF-8
The script prints every file it writes. On Windows the console isn't UTF-8 by default, and printing those fancy letters breaks. The files themselves are fine because I open them with encoding="utf-8" anyway. It's just the print.
python -I -X utf8 export.py
-X utf8 turns on Python's UTF-8 mode. -I is isolated mode, so nothing from the current folder or environment sneaks into the imports. I use that for any script that handles data I didn't write.
Gotcha: the bot sees more than you want
This is the part that matters most. "View Channels" is per server, and a bot with that role sees every channel the role can see. On this server that included the staff chat and the moderation logs.
I didn't touch those for the docs. The question to answer list says that right at the top, so whoever reviews it knows. And there are no Discord names anywhere in the docs. Not the people who asked, not the people who answered. The docs explain how things work, they don't quote anybody.
Next time I'd lock the bot out of staff channels with channel permission overrides before the first export. Reading less is better than promising not to look.
Step 3: questions and answers, then the code
I didn't write docs straight from the chat. First I made a question to answer list in Markdown. 12 topics: what TalePainter is, download and install, first start, RAM and performance, export to Hytale, height, terrain, layers and caves, prefabs and trees, biomes, WorldPainter and Minecraft, help.
Every answer got a status:
| Status | Meaning |
|---|---|
| confirmed | someone said it worked |
| team answer | the team said so, nobody confirmed |
| known bug | still broken in the current release |
| fixed | fixed in a release |
| Hytale issue | not a TalePainter problem |
| needs input | I don't know, the team has to answer |
Newer info wins over older, and contradictions are marked instead of quietly picking one.
Then the code check. Chat answers are often half right, or were right three versions ago. The source is public, so I checked directly:
- The height setting offers 320, 512, 640 and 1024. Only 320 loads in vanilla Hytale. That's now a warning on the export page.
- Asset setup: "Locate Assets" just needs the launcher folder. No unpacking, even though people in chat did all sorts of things.
- The RAM config file path on macOS and on Linux, taken from the packaging code, not from memory.
- The macOS
.dmgof the last release ships an ARM64-only launcher. I checked the binary. That went on the open questions list.
Some fixes were already on the main branch but not released yet. So the known issues page describes the released version, and gets updated after the next release.
The open questions at the end of the list (code signing, where downloads live, the issue tracker) I answered myself, since I know the project. The answers went into the list, and only then I started writing pages.
Step 4: Astro Starlight in three languages
The site is Astro with Starlight 0.42. 17 pages per language, English at the root, German under /de/, Spanish under /es/. The sidebar groups get translated labels with a tiny helper:
const group = (en, de, es, items) => ({ label: en, translations: { de, es }, items });
starlight({
defaultLocale: 'root',
locales: {
root: { label: 'English', lang: 'en' },
de: { label: 'Deutsch', lang: 'de' },
es: { label: 'Español', lang: 'es' },
},
sidebar: [
group('Getting started', 'Erste Schritte', 'Primeros pasos', [
'getting-started/what-is-talepainter',
'getting-started/install',
'getting-started/first-start',
]),
// guides, troubleshooting, reference ...
],
});
The pages under de/ and es/ use the same slugs as the English ones. Starlight matches them by path and shows the language switcher on its own.
English first, German after review, Spanish last. I don't speak Spanish well enough to sign off on it, so that part still needs a second check before anyone relies on it. The colours are taken from the main TalePainter site, so it doesn't look like a random template.
Step 5: deploy with tar and ssh
It's a static site. No Node on the server, no container. Build locally, pack it, swap the folder.
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
npx astro build
H=root@203.0.113.10
D=/var/www/docs.example.com
tar -czf /tmp/docs.tgz -C dist .
scp -q /tmp/docs.tgz $H:/tmp/docs.tgz
ssh $H "set -e; rm -rf $D.new; mkdir -p $D.new; tar -xzf /tmp/docs.tgz -C $D.new; \
rm -rf $D.old; [ -d $D ] && mv $D $D.old; mv $D.new $D; rm -rf $D.old /tmp/docs.tgz"
rm -f /tmp/docs.tgz
curl -s -o /dev/null -w "http %{http_code}\n" --resolve docs.example.com:80:203.0.113.10 http://docs.example.com/
Unpacking into .new first and then renaming means visitors never see a half-copied site. The curl --resolve at the end hits the server directly, even if DNS isn't there yet. On the real box there's also a chown to the web user, because the panel expects that. Starlight builds a real HTML file per page, so unlike an SPA there's no fallback rule to set up. The domain itself sits in KeyHelp like any other site.
What's still open
The dedicated server guide is built from the export folder layout in the code. It should be tested once on a real server. If you run one, my notes on Hytale server files and the install prep cover the server side.
Next step is pointing the Discord FAQ and the main website at the docs. Docs nobody links to don't stop the weekly repeat question.
What I'd do next time
Lock the bot out of private channels before exporting. Put channel IDs in file names from the start. Write the question to answer list before any page, and check every answer against the code, not against the loudest message in the chat. And if you want Discord and a forum to stay in sync after that, I did that for another community in the forum to Discord bridge.