Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/trustlessmatt/discord-exporter-bot/llms.txt

Use this file to discover all available pages before exploring further.

Installation Guide

This guide covers everything you need to install and configure the Discord Exporter Bot, including Discord bot setup, Python installation, Docker deployment, and environment configuration.

Setting Up Your Discord Bot

1

Create a Discord Application

  1. Go to the Discord Developer Portal
  2. Click New Application
  3. Give your application a name (e.g., “Team Exporter Bot”)
  4. Click Create
2

Create a Bot User

  1. In your application, navigate to the Bot tab in the left sidebar
  2. Click Add Bot and confirm
  3. Under the bot’s username, click Reset Token to generate a new token
  4. Copy this token - you’ll need it for your .env file
Keep your bot token secret! Never share it or commit it to version control. If exposed, reset it immediately in the Developer Portal.
3

Enable Required Intents

Scroll down to Privileged Gateway Intents and enable:
  • Message Content Intent (required to read message contents)
  • Server Members Intent (required for member information)
Click Save Changes.
4

Invite the Bot to Your Server

  1. Navigate to the OAuth2URL Generator tab
  2. Under Scopes, select:
    • bot
  3. Under Bot Permissions, select:
    • Read Messages/View Channels
    • Read Message History
    • Send Messages
  4. Copy the generated URL at the bottom
  5. Open the URL in your browser and select your server
  6. Click Authorize
5

Get Your Guild ID

  1. Open Discord and go to User SettingsAdvanced
  2. Enable Developer Mode
  3. Right-click your server icon and select Copy Server ID
  4. Save this ID - you’ll need it for your .env file

Python Installation

Requirements

  • Python 3.11 or higher (required for zoneinfo support)
  • pip (Python package installer)

Installing Python

Using Homebrew:
brew install python@3.11
Verify installation:
python3 --version
# Should show Python 3.11.x or higher

Setting Up the Project

1

Create project directory

mkdir discord-exporter-bot
cd discord-exporter-bot
2

Create and activate virtual environment (recommended)

python3 -m venv venv
source venv/bin/activate
Using a virtual environment keeps your bot’s dependencies isolated from other Python projects.
3

Add bot.py and requirements.txt

Copy the bot.py file into your project directory.Create requirements.txt with the following dependencies:
requirements.txt
discord.py==2.3.2
python-dotenv==1.0.0
anthropic==0.40.0
4

Install dependencies

pip install -r requirements.txt
This installs:
  • discord.py - Discord API wrapper for Python
  • python-dotenv - Load environment variables from .env files
  • anthropic - Anthropic Claude API client for AI digests

Environment Configuration

Creating Your .env File

Create a .env file in your project directory. Use this template based on .env.example:
.env
# Required
DISCORD_TOKEN=your_discord_bot_token_here
GUILD_ID=your_discord_server_id_here

# Optional - AI Digest Features
ANTHROPIC_API_KEY=your_anthropic_api_key_here

# Optional - Custom Output Path
DOKPLOY_VOLUME_PATH=/path/to/obsidian/vault

# Optional - GitHub Sync
GITHUB_REPO_URL=https://github.com/username/repo.git
GITHUB_TOKEN=your_github_personal_access_token

Environment Variables Reference

DISCORD_TOKEN
string
required
Your Discord bot token from the Developer Portal.How to get it: Bot tab → Reset Token → Copy
GUILD_ID
integer
required
Your Discord server’s ID.How to get it: Enable Developer Mode → Right-click server → Copy Server ID
ANTHROPIC_API_KEY
string
Your Anthropic API key for Claude AI digests.How to get it: Sign up at console.anthropic.com and create an API keyNote: The bot will run without this, but !digest command won’t work.
DOKPLOY_VOLUME_PATH
string
Custom path for digest output. Useful for saving directly to an Obsidian vault.Default: Saves to ./Daily Digests/ in the project directoryExample: /Users/yourname/Documents/Obsidian/TeamVault
GITHUB_REPO_URL
string
GitHub repository URL for auto-syncing digests.Format: https://github.com/username/repository.gitRequires: GITHUB_TOKEN must also be set
GITHUB_TOKEN
string
GitHub personal access token with repo scope.How to get it: GitHub Settings → Developer settings → Personal access tokens → Generate new token (classic) → Select repo scopeNote: The bot will commit digests with author “Discord Bot <bot@discord.local>

Getting an Anthropic API Key

1

Sign up for Anthropic

Visit console.anthropic.com and create an account.
2

Add credits

Navigate to billing and add credits to your account. Claude API usage is pay-as-you-go.
Daily digests typically use 10-50K tokens depending on message volume. At current pricing, this costs $0.01-0.05 per digest.
3

Generate API key

Go to API Keys section and click Create Key. Copy the key and add it to your .env file.

Docker Installation

For production deployments, Docker provides a clean, isolated environment.

Dockerfile

The bot includes a Dockerfile:
Dockerfile
FROM python:3.11-slim

# Install git (required for GitHub sync)
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy bot code
COPY bot.py .

# Create directories
RUN mkdir -p /app/exports /app/digests

# Run the bot
CMD ["python", "-u", "bot.py"]

Building and Running

1

Build the Docker image

docker build -t discord-exporter-bot .
2

Run the container

docker run -d \
  --name discord-bot \
  --env-file .env \
  -v $(pwd)/exports:/app/exports \
  -v $(pwd)/digests:/app/Daily\ Digests \
  discord-exporter-bot
This command:
  • Runs the container in detached mode (-d)
  • Names the container discord-bot
  • Loads environment variables from .env
  • Mounts volumes for exports and digests (persists data outside container)
3

View logs

docker logs -f discord-bot
Press Ctrl+C to stop following logs.
4

Stop the bot

docker stop discord-bot
5

Restart the bot

docker start discord-bot
Make sure your .env file is in the same directory when running Docker commands, and never include it in your Docker image.

Docker Compose (Optional)

For easier management, create a docker-compose.yml:
docker-compose.yml
version: '3.8'

services:
  discord-bot:
    build: .
    container_name: discord-exporter-bot
    env_file:
      - .env
    volumes:
      - ./exports:/app/exports
      - ./digests:/app/Daily Digests
    restart: unless-stopped
Then run:
# Start
docker-compose up -d

# View logs
docker-compose logs -f

# Stop
docker-compose down

Verification Steps

After installation, verify everything is working:
1

Check bot connection

Run the bot and look for these log messages:
INFO - BotName#1234 has connected to Discord!
INFO - Bot is in 1 guild(s)
INFO - Connected to: Your Server Name
INFO - Text channels: 5
INFO - Daily digest task started
If you don’t see these messages, check that your DISCORD_TOKEN and GUILD_ID are correct in .env.
2

Test export command

In a Discord channel, type:
!export 1
Expected response:
Starting export of last 1 hours...
✅ Export complete!
• X messages
• Y channels
• Saved to `exports/discord_export_YYYYMMDD_HHMMSS_ET.json`
Check that the JSON file was created in the exports/ directory.
3

Test digest command (if using Claude)

In a Discord channel, type:
!digest 1
Expected response:
🤖 Generating digest for last 1 hours...
✅ Daily Digest Generated
[Preview of digest content]
📁 Full digest: `Daily Digests/YYYY-MM-DD - Team Digest.md`
Check that the Markdown file was created in the Daily Digests/ directory (or your custom DOKPLOY_VOLUME_PATH).
4

Verify GitHub sync (if configured)

If you set up GitHub sync, after running !digest, check your GitHub repository to see if the commit was pushed:
  1. Go to your GitHub repository
  2. Look for a commit with message “Daily digest for YYYY-MM-DD”
  3. Verify the digest file is in the repository
Check bot logs for:
INFO - Successfully pushed [filename] to GitHub
5

Wait for scheduled digest (optional)

The bot automatically runs a digest at midnight ET. Check logs the next day:
INFO - Running scheduled daily digest
INFO - ✅ Daily digest completed successfully

Troubleshooting

Symptoms: No log messages, or “Invalid token” errorSolutions:
  • Verify your DISCORD_TOKEN is correct in .env
  • Make sure you copied the token immediately after generating it (they’re only shown once)
  • Reset the token in Discord Developer Portal if needed
  • Check that .env file is in the same directory as bot.py
Symptoms: Bot is online, but !export and !digest do nothingSolutions:
  • Verify Message Content Intent is enabled in Discord Developer Portal
  • Make sure the bot has permissions to read and send messages in the channel
  • Check that you’re using the correct command prefix (!)
  • Look for permission errors in the logs
Symptoms: !export succeeds but !digest returns an errorSolutions:
  • Verify ANTHROPIC_API_KEY is set in .env
  • Check that your Anthropic account has available credits
  • Test your API key with a simple curl request
  • Look for Claude API errors in the logs
Symptoms: Digest generates but doesn’t appear in GitHubSolutions:
  • Verify both GITHUB_REPO_URL and GITHUB_TOKEN are set
  • Check that your token has repo scope
  • Ensure the repository exists and you have push access
  • Look for git errors in the logs
  • Make sure git is installed (required for GitHub sync)
Symptoms: Export JSON shows empty content or unresolved mentions like <@123456>Solutions:
  • Enable Message Content Intent in Discord Developer Portal (required)
  • Enable Server Members Intent for proper member name resolution
  • Restart the bot after enabling intents

Next Steps

Configuration

Learn about environment variables and configuration options

Commands

Explore available commands and features

GitHub Integration

Set up GitHub sync and Obsidian integration

Usage Guide

Learn all commands and features

Integration

Connect with Obsidian and workflows

Build docs developers (and LLMs) love