An AI-powered Discord bot designed to assist with programming tasks, document management, and project collaboration. The bot integrates multiple AI models, provides intelligent context retrieval, and maintains conversation memory to create a seamless development assistance experience.
- π€ Multi-AI Model Support: Chat with OpenAI GPT-4o/o1 series and Anthropic Claude 4.0 models
- π§ Intelligent Context: Semantic search through conversation history using vector databases
- π Document Management: Upload, analyze, and query documents (PDF, code files, etc.)
- π GitHub Integration: Track repositories, search code, manage issues and pull requests
- πΎ Memory System: Remember and recall important project context
- π Smart Search: Find relevant information across conversations, documents, and memories
- Python 3.12+
- Discord Bot Token
- API Keys for OpenAI and/or Anthropic
- Pinecone API Key (for vector database)
- AWS S3 Bucket (for file storage)
- GitHub Token (for repository integration)
- Clone the repository:
git clone <repository-url>
cd PairProgrammer
- Install dependencies:
pip install -r requirements.txt
- Create a
.env
file with your configuration:
# Required
DISCORD_TOKEN=your_discord_bot_token
OPENAI_API_KEY=your_openai_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key
PINECONE_API_KEY=your_pinecone_api_key
PINECONE_INDEX_NAME=discord-pair-programmer
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
S3_BUCKET_NAME=your_s3_bucket_name
GITHUB_TOKEN=your_github_token
# Optional
DEBUG=false
DB_TYPE=sqlite
DATABASE_URL=sqlite:///bot_memory.db
- Run the bot:
python main.py
All commands use the !
prefix. Most commands have multiple aliases for convenience.
Command | Aliases | Description | Usage |
---|---|---|---|
!chat |
c , ask , ai |
Chat with AI models with context | !chat openai chatgpt-4o-latest How do I implement async? |
!quick |
q , gpt , ask4 |
Quick chat with default GPT-4 model | !quick How do I use decorators? |
!models |
model , list_models |
List available AI models | !models |
!search |
s , find , lookup |
Search conversation history | !search authentication |
!context |
ctx , preview |
Show context for a query | !context recent conversations |
!autosave |
as , auto |
Toggle auto-saving conversations | !autosave |
Command | Aliases | Description | Usage |
---|---|---|---|
!upload |
up , add , attach |
Upload files with description | !upload "API docs" + attach file |
!files |
f , list , ls , docs |
List uploaded files | !files or !files @user |
!askdoc |
ad , question , qd |
Ask questions about documents | !askdoc 123 What is the main idea? |
!fileinfo |
fi , details |
Get file information | !fileinfo 123 |
!getfile |
get , download |
Get download link | !getfile 123 |
!papers |
p , documents , pdfs |
List documents with filters | !papers pdf |
!deletefile |
delete , rm |
Delete files (owner only) | !deletefile 123 |
Command | Aliases | Description | Usage |
---|---|---|---|
!remember |
r , save , mem |
Save important context | !remember auth_setup Using JWT for authentication |
!recall |
rc , find_memory |
Search memories | !recall authentication |
!get_memory |
gm , memory |
Get specific memory by tag | !get_memory auth_setup |
!list_memories |
lm , memories |
List all memory tags | !list_memories |
!forget |
fg , delete_memory |
Delete memories | !forget old_project |
!stats |
st , statistics |
Show database statistics | !stats |
Command | Aliases | Description | Usage |
---|---|---|---|
!address |
add_repo , track |
Track GitHub repository | !address user/repo |
!repos |
repositories , lr |
List tracked repositories | !repos |
!repoinfo |
repo , about |
Get repository information | !repoinfo user/repo |
!issues |
i , bugs |
List repository issues | !issues user/repo |
!prs |
pr , pulls |
List pull requests | !prs user/repo |
!codesearch |
cs , code , grep |
Search code in repository | !codesearch user/repo function_name |
!createissue |
ci , newissue |
Create new issue | !createissue user/repo "Title" Description |
!removerepo |
rr , untrack |
Stop tracking repository | !removerepo user/repo |
Command | Aliases | Description | Usage |
---|---|---|---|
!help |
h , ? , commands |
Show command help | !help or !help ai |
!commands_table |
ct , table |
Compact command table | !commands_table |
!tips |
tip , hints |
Show usage tips | !tips |
!aliases |
a , shortcuts |
Show command aliases | !aliases |
!quick How do I implement binary search in Python?
!chat anthropic claude-sonnet-4-0 Explain async/await in JavaScript
!upload "Project requirements document"
# Attach your PDF file
!askdoc 1 What are the main requirements?
!files # List all uploaded documents
!remember project_stack We're using React frontend with Node.js backend
!remember db_choice Decided on PostgreSQL for the database
!recall database # Find all memories about database choices
!address microsoft/vscode # Track the VS Code repository
!issues microsoft/vscode # See recent issues
!codesearch microsoft/vscode editor.action # Search for code
SQLite (Default):
DB_TYPE=sqlite
DATABASE_URL=sqlite:///bot_memory.db
MySQL:
DB_TYPE=mysql
DB_USERNAME=username
DB_PASSWORD=password
DB_HOST=localhost
DB_PORT=3306
DB_NAME=discord_bot
The bot can process these file types:
- Documents: PDF, TXT, MD
- Code: PY, JS, TS, JSON, YAML, YML
- Data: CSV, LOG
- Max file size: 25MB (Discord limit)
OpenAI Models:
- gpt-4o, chatgpt-4o-latest, gpt-4o-mini
- o1, o1-preview, o1-mini, o3-mini
- gpt-4, gpt-4-turbo, gpt-3.5-turbo
Anthropic Models:
- claude-opus-4-0, claude-sonnet-4-0
- claude-3-5-sonnet-latest, claude-3-5-haiku-latest
- claude-3-opus-latest
The bot follows a modular architecture with these components:
main.py
: Bot initialization and entry pointconfig.py
: Configuration managementdatabase/
: SQLAlchemy models and database operationsservices/
: AI, vector database, GitHub, and S3 servicescogs/
: Discord command handlers organized by featureutils/
: Logging and utility functions
The bot requires these Discord permissions:
- Send Messages
- Read Message History
- Use Slash Commands
- Attach Files
- Embed Links
- Read Messages
Admin commands require Discord Administrator permissions.
Most commands have cooldowns (3 uses per 60 seconds per user) to prevent spam and manage API costs. The bot includes automatic retry logic for API rate limits.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
[Add your license information here]
Bot not responding:
- Check Discord token validity
- Verify bot has required permissions
- Check console logs for errors
AI commands failing:
- Verify API keys in
.env
file - Check rate limits on AI providers
- Ensure Pinecone index exists
File uploads not working:
- Verify AWS S3 credentials and bucket access
- Check file size (Discord 25MB limit)
- Ensure supported file type
GitHub integration issues:
- Verify GitHub token permissions
- Check repository URL format
- Ensure repository is public or token has access
Use the !help
command for in-bot assistance, or !tips
for best practices and usage tips.
Note: This bot is designed for development teams and programming assistance. Always review AI-generated code before using in production.