Overview
The TL;DR feature allows users to generate AI-powered summaries of Discord conversations. It fetches recent messages and uses a language model to create concise bullet-point summaries.Command Usage
The.tldr command is a self-bot command that summarizes recent conversation history:
- count (optional): Number of messages to summarize (default: 50)
Example
Implementation
Command Setup
The TL;DR command is registered as a bot command:discord_bot/tldr.py:26-38
LLM Client Configuration
The feature uses Groq’s API with an OpenAI-compatible client:discord_bot/tldr.py:16-19
Required Environment Variable:
GROQ_API_KEY: Your Groq API key
Message Fetching
The system fetches recent messages while filtering out existing TL;DR summaries:discord_bot/tldr.py:46-61
Key Features
- Filters existing summaries: Prevents summarizing previous TL;DR outputs
- Chronological order: Reverses messages to maintain conversation flow
- Error handling: Graceful failure with user notification
- Auto-delete errors: Error messages disappear after 10 seconds
Summarization
Prompt Building
Messages are formatted with timestamps and author names:discord_bot/tldr.py:77-87
Format Example:
AI Model Configuration
The system uses Groq’s Llama model for fast, accurate summaries:discord_bot/tldr.py:64-74
Model Parameters
- Model:
llama-3.1-70b-versatile - Temperature: 0.4 (balanced creativity and consistency)
- Output: 4-6 bullet points
Response Formatting
Text Chunking
Long summaries are automatically split to respect Discord’s message limits:discord_bot/tldr.py:90-91
- Chunk size: 1800 characters (safe margin below Discord’s 2000 limit)
- Automatic splitting: Handles very long summaries gracefully
Output Format
Each chunk is sent with a “TL;DR” header:discord_bot/tldr.py:37-38
Self-Bot Protection
The command includes self-bot authorization to prevent misuse:discord_bot/tldr.py:29-32
- Authorization check: Only the bot owner can trigger summaries
- Auto-delete: Original command message is deleted after 1.5 seconds
- Clean interface: Keeps channels tidy
Usage Workflow
- User sends
.tldr 50command - Bot verifies the user is the bot owner
- Original command message is deleted
- Bot fetches last 50 messages (excluding existing TL;DRs)
- Messages are formatted and sent to Groq API
- AI generates 4-6 bullet point summary
- Summary is chunked and posted with “TL;DR” header
Error Handling
Fetch Errors
API Errors
discord_bot/tldr.py:64-74
Configuration
Environment Variables
Customization Options
- Default message count: Modify
count: int = 50parameter - Summary length: Adjust prompt to request more/fewer bullet points
- Model selection: Change
modelparameter to different Groq models - Temperature: Adjust for more creative (higher) or consistent (lower) summaries
- Chunk size: Modify
size: int = 1800for different splitting behavior
Best Practices
-
Message count: Use 30-100 messages for best results
- Too few: Summary may lack context
- Too many: May hit token limits or lose coherence
-
Channel types: Works best in active discussion channels
- May produce generic summaries in low-activity channels
-
Frequency: Avoid spamming summaries
- Existing TL;DRs are automatically filtered to prevent recursion
-
Privacy: Be mindful when summarizing sensitive conversations
- Summaries are posted publicly in the channel