A Discord bot that searches Anna's Archive for books and downloads them directly to your home server.
- 🔍 Search for books by title, author, or both
- 📋 Get top 5 matching results with details (format, size, language)
- 🖱️ Interactive button selection for easy downloading
- 💾 Downloads books directly to your server
- 🐳 Easy Docker deployment
- Go to the Discord Developer Portal
- Click "New Application" and give it a name
- Go to the "Bot" section and click "Add Bot"
- Under "Privileged Gateway Intents", enable:
- Message Content Intent (required for prefix commands)
- Click "Reset Token" and copy your bot token
- Go to "OAuth2" → "URL Generator"
- Select scopes:
bot,applications.commands - Select permissions:
Send Messages,Embed Links,Use Slash Commands - Copy the generated URL and use it to invite the bot to your server
# Clone or copy these files to your server
cd annas-discord-bot
# Create your .env file
cp .env.example .env
# Edit .env and add your Discord token
nano .env
# Start the bot
docker compose up -dOnce the bot is online in your Discord server:
/book 1984 # Search by title
/book Dune Frank Herbert # Search by title and author
/search title:1984 # Alternative search command
!book Project Hail Mary # Prefix command alternative
/help # Show help
| Variable | Required | Default | Description |
|---|---|---|---|
DISCORD_TOKEN |
Yes | - | Your Discord bot token |
BOOKS_DIR |
No | /books |
Directory to save downloaded books |
ANNAS_BASE_URL |
No | https://annas-archive.org |
Anna's Archive URL |
By default, books are saved to ./books on your host machine. To change this, edit docker-compose.yml:
volumes:
- /path/to/your/books:/books # Change the left side| Command | Description |
|---|---|
/book <query> |
Search for a book |
/search <title> [author] |
Search with separate title/author fields |
!book <query> |
Prefix command (alternative to slash commands) |
/help |
Show help information |
- Search: When you search, the bot queries Anna's Archive and parses the top 5 results
- Select: Results are displayed with interactive buttons - click to select
- Download: The bot fetches the download link and saves the file to your server
- Done: You get a confirmation with the filename
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Discord User │────▶│ Discord Bot │────▶│ Anna's Archive │
│ │◀────│ (Container) │◀────│ │
└─────────────────┘ └────────┬─────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ /books volume │
│ (Your Server) │
└─────────────────┘
- Make sure the bot is online (check
docker compose logs) - Ensure you enabled "Message Content Intent" in Discord Developer Portal
- Wait a few minutes for slash commands to sync (can take up to an hour)
- Some books may have dead download links
- Try a different search result
- Check bot logs:
docker compose logs -f
# Make sure the books directory is writable
chmod 755 ./booksdocker compose logs -f book-botdocker compose restartdocker compose up -d --buildIf you prefer to run without Docker:
# Install Python 3.10+
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
pip install -r requirements.txt
# Set environment variables
export DISCORD_TOKEN=your_token_here
export BOOKS_DIR=/path/to/books
# Run the bot
python bot.pyThis bot is for personal use only. Respect copyright laws in your jurisdiction. The bot simply automates searching and downloading from Anna's Archive - it does not host any content itself.
MIT License - feel free to modify and use as you wish.