A Discord bot that integrates with AWS Rekognition to provide image analysis, face detection, text extraction, celebrity recognition, content moderation, and face comparison directly within Discord servers.
This bot can be used in OSINT workflows that involve image analysis, such as object identification, text extraction, and face comparison.
Click to expand
- Object & Scene Detection: Identify thousands of objects, scenes, and concepts
- Text Extraction (OCR): Extract text from images with high accuracy
- Face Analysis: Detect faces with demographics, emotions, and facial attributes
- Celebrity Recognition: Identify famous people in images
- Content Moderation: Automatically detect inappropriate content
- Face Comparison: Compare faces between two images with similarity scoring
- Batch Processing: Analyze multiple features simultaneously
- AWS-Powered: Uses AWS Rekognition's machine learning models
- Detailed Reports: Export comprehensive JSON analysis reports
- Image Support: Works with URLs and uploaded images (JPEG, PNG)
- Real-time Processing: Fast analysis with progress indicators
- Error Handling: Robust error management with user-friendly messages
- Slash Commands: Modern Discord interface with autocomplete
- Visual Results: Rich embeds with thumbnails and organized data
- File Attachments: Detailed JSON reports for further analysis
- Progress Updates: Real-time status updates during processing
- Smart Validation: Input validation and helpful error messages
Perform comprehensive image analysis with multiple AI features.
Options:
url(optional): Direct image URL to analyzeimage(optional): Upload an image file to analyzefeatures(optional): Specific features to analyze
Available Features:
- All Features (Recommended): Run complete analysis
- Labels & Objects: Detect objects, scenes, and concepts
- Text Detection (OCR): Extract text from images
- Face Analysis: Analyze faces, emotions, and demographics
- Content Moderation: Check for inappropriate content
- Celebrity Recognition: Identify famous people
Example:
/rekognition analyze image:[upload] features:All Features
/rekognition analyze url:https://example.com/image.jpg features:Face Analysis
Compare faces between two images with similarity scoring.
Options:
source_url/source_image: Reference image with the face to matchtarget_url/target_image: Image to search for matching facessimilarity(optional): Minimum similarity threshold (0-100, default: 80)
Example:
/rekognition compare source_image:[upload1] target_image:[upload2] similarity:75
/rekognition compare source_url:https://example.com/face1.jpg target_url:https://example.com/face2.jpg
- Node.js v18.0.0 or higher (or Bun v1.0+)
- Docker (optional, recommended for production)
- Discord Application and bot token
- AWS Account with Rekognition access
- AWS IAM User with appropriate permissions
git clone https://github.com/gl0bal01/discord-amazon-rekognition.git
cd discord-amazon-rekognitionbun installcp .env.example .envEdit .env with your configuration:
# Discord Configuration
DISCORD_TOKEN=your_discord_bot_token_here
CLIENT_ID=your_discord_application_client_id_here
GUILD_ID=your_development_server_id_here
# AWS Configuration
AWS_ACCESS_KEY_ID=your_aws_access_key_id_here
AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key_here
AWS_REGION=us-east-1Sign up at aws.amazon.com if you don't have an account.
- Go to IAM Console β Users β Create User
- Choose "Programmatic access"
- Create or attach a policy with these permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"rekognition:DetectLabels",
"rekognition:DetectText",
"rekognition:DetectFaces",
"rekognition:DetectModerationLabels",
"rekognition:RecognizeCelebrities",
"rekognition:CompareFaces"
],
"Resource": "*"
}
]
}- Copy the Access Key ID and Secret Access Key
- Add them to your
.envfile
Select the region closest to your users:
us-east-1(N. Virginia) - Defaultus-west-2(Oregon)eu-west-1(Ireland)ap-southeast-1(Singapore)
- Go to Discord Developer Portal
- Click "New Application" and name your bot
- Go to "Bot" section and create a bot
- Copy the Bot Token to your
.envfile
- In the "General Information" section
- Copy the Application ID (this is your Client ID)
Your bot needs these permissions:
Send Messages(2048)Use Slash Commands(2147483648)Attach Files(32768)Embed Links(16384)
Permission Integer: 2147516160
# Development (instant deployment to test server)
bun run deploy
# Production (global deployment - takes up to 1 hour)
bun run deploy:global# Production
bun run start
# Development with auto-restart
bun run dev# Build
docker build -t rekognition-bot .
# Run
docker run -d \
--name rekognition-bot \
--read-only \
--tmpfs /app/temp:rw,noexec,nosuid,size=100m \
--memory=512m \
--cpus=1.0 \
--pids-limit=50 \
--security-opt=no-new-privileges:true \
--env-file .env \
--restart unless-stopped \
rekognition-botLook for these startup messages:
β
Loaded command: rekognition
π Created temporary files directory
π― Discord Amazon Rekognition Bot is ready!
π Logged in as: YourBotName#1234
Use this URL to invite your bot (replace YOUR_CLIENT_ID):
https://discord.com/api/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=2147516160&scope=bot%20applications.commands
Required Permissions:
- Send Messages: Respond to commands
- Use Slash Commands: Register slash commands
- Attach Files: Send analysis reports and images
- Embed Links: Display rich result embeds
discord-amazon-rekognition/
βββ commands/
β βββ rekognition.js # Main Rekognition command
βββ tests/
β βββ rekognition.test.js # Unit tests (bun test)
βββ temp/ # Temporary file storage (auto-created)
βββ .dockerignore # Docker build exclusions
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
βββ deploy-commands.js # Command deployment script
βββ Dockerfile # Multi-stage production container
βββ index.js # Main bot application
βββ LICENSE # MIT license
βββ package.json # Dependencies and scripts
βββ README.md # This documentation
/rekognition analyze
π Upload: family_photo.jpg
π― Features: All Features
Results:
- Objects: Person (99.5%), Clothing (95.2%), Smile (87.1%)
- Text: "Happy Birthday!" extracted from banner
- Faces: 3 faces detected with age ranges and emotions
- JSON Report: Detailed technical analysis attached
/rekognition compare
π Source: person1.jpg
π Target: group_photo.jpg
π Similarity: 75%
Results:
- Match Found: 89.2% similarity detected
- Additional Faces: 4 unmatched faces in target image
- Comparison Report: Detailed matching data
/rekognition analyze
π URL: https://example.com/document.jpg
π― Features: Text Detection (OCR)
Results:
- Extracted Text: All readable text from the image
- Confidence Scores: Accuracy ratings for each text element
- Bounding Boxes: Location data in JSON report
| Metric | Value |
|---|---|
| Analysis Speed | Varies by image size, network latency, and AWS region |
| Supported Formats | JPEG, PNG |
| Max Image Size | 5MB (JPEG), 8MB (PNG) |
| Accuracy | Depends on feature and image quality; see AWS Rekognition documentation for details |
| Concurrent Requests | 10 (configurable) |
Solution:
- Verify
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYare in.env - Check that credentials are valid
- Ensure IAM user has Rekognition permissions
Solution:
- Use JPEG or PNG format only
- Ensure image file is not corrupted
- Check image size limits (5MB JPEG, 8MB PNG)
Solution:
- Ensure faces are clearly visible and well-lit
- Use higher resolution images
- Avoid heavily obscured or profile faces
Solution:
- Run
bun run deployto update commands - Check
CLIENT_IDis correct in.env - Wait up to 1 hour for global command deployment
Enable detailed logging:
NODE_ENV=developmentMonitor your usage at AWS Billing Console:
- Free Tier: 5,000 images/month for first 12 months
- Standard Pricing: $1-5 per 1,000 images (varies by feature)
- Rate Limits: 50 TPS (transactions per second)
- Image Size: 5MB JPEG, 8MB PNG
- Image Resolution: Minimum 80 pixels for face detection
- Concurrent Requests: 50 per account
- Message Size: 2000 characters
- File Upload: 25MB (Discord Nitro: 100MB)
- Embeds: 25 fields per embed
- No Image Storage: Images are processed and immediately deleted
- Temporary Files: Auto-cleanup after 10 seconds per request
- AWS Security: All data encrypted in transit and at rest
- No Logging: Personal image data is never logged
- SSRF Protection: DNS resolution + private IP blocking (IPv4, IPv6, IPv4-mapped IPv6, 6to4, Teredo) with pinned HTTP agents to prevent DNS rebinding
- Path Traversal Prevention: Random filenames with extension allowlisting
- Magic Bytes Validation: File signatures verified (JPEG, PNG, GIF, BMP, WebP)
- Rate Limiting: Per-user cooldown + global concurrency limit
- Error Sanitization: Internal errors never exposed to users
- Docker: Runs as non-root, read-only filesystem, tini init, pinned base image
- Use IAM roles (preferred) or static credentials with minimal permissions
- Deploy with Docker using the recommended
docker runflags - Regularly rotate access keys if using static credentials
- Monitor AWS CloudTrail logs
- Keep dependencies updated (
bun update)
The bot includes automatic content moderation features to detect:
- Explicit content
- Suggestive content
- Violence
- Visually disturbing content
- Fork the repository
- Create a feature branch
- Implement your changes
- Add appropriate error handling
- Update documentation
- Submit a pull request
This bot uses AWS SDK v3 for better performance:
const { RekognitionClient, DetectLabelsCommand } = require('@aws-sdk/client-rekognition');
const client = new RekognitionClient({ region: 'us-east-1' });
const command = new DetectLabelsCommand(params);
const response = await client.send(command);bun test110 unit tests covering SSRF protection, magic bytes validation, URL validation, extension sanitization, and IPv6 edge cases.
| Resource | Link |
|---|---|
| π AWS Rekognition Docs | AWS Documentation |
| π Report Bug | GitHub Issues |
| β¨ Request Feature | Feature Request |
| π¬ Discord Support | Join Server |
| π§ AWS Console | AWS Management Console |
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Create an issue for bug reports
- Join our Discord server for support
- Check AWS Rekognition documentation for API questions
- Review Discord.js guide for bot development help
- AWS Rekognition - Cloud-based computer vision service
- Discord.js - Excellent Discord API library
- Discord Developer Portal - Bot development platform
- AWS SDK for JavaScript - Official AWS SDK



