One-shot CLI that pulls recent Discord messages, normalizes them, and exports JSON + RSS. It is not a server, web app, or long-running bot; it runs once, writes files, and exits.
- Connects to Discord with a bot token
- Reads channel history (no event listeners)
- Normalizes messages into a consistent schema
- Exports to
output/news.jsonandoutput/news.xmlby default
- No web UI
- No database or persistent service
- No background worker or
on_messagelistener
- Python 3.10+
- Discord bot token with permission to read target channels
- Environment variables configured (see below)
python -m venv .venv
source .venv/bin/activate
pip install -e .All settings come from environment variables (no prompts):
DISCORD_BOT_TOKEN(required)DISCORD_CHANNEL_IDS(required, comma-separated IDs)MESSAGES_LIMIT(optional, default 50, max 200; per channel)OUTPUT_JSON_PATH(defaultoutput/news.json)OUTPUT_RSS_PATH(defaultoutput/news.xml)SITE_BASE_URL(optional, used for RSS<link>)FEED_TITLE/FEED_DESCRIPTION(optional RSS metadata)FEED_LANGUAGE(defaulten)
Example .env:
DISCORD_BOT_TOKEN=your-bot-token-here
DISCORD_CHANNEL_IDS=123456789012345678,987654321098765432
MESSAGES_LIMIT=50
OUTPUT_JSON_PATH=output/news.json
OUTPUT_RSS_PATH=output/news.xml
SITE_BASE_URL=https://example.com
FEED_TITLE=Community Updates
FEED_DESCRIPTION=Latest posts from our Discord
FEED_LANGUAGE=en
export DISCORD_BOT_TOKEN=...
export DISCORD_CHANNEL_IDS=123456789012345678,987654321098765432
python -m discord_fetcher.cliOptional overrides:
python -m discord_fetcher.cli --limit 100 --json-path data/discord.json --rss-path data/discord.xml- name: Fetch Discord news
run: python -m discord_fetcher.cli
env:
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
DISCORD_CHANNEL_IDS: ${{ secrets.DISCORD_CHANNEL_IDS }}
MESSAGES_LIMIT: 50- JSON: array of normalized messages (newest first), UTF-8,
indent=2,ensure_ascii=False. - RSS: RSS 2.0 feed capped at 50 newest items, UTF-8 XML.
- Bot messages are skipped.
- Attachments are exported as links only.
- The tool exits after writing output files; no listeners remain active.