Project Structure
The bot code is located inapps/discord-bot/src/:
Creating Commands
Commands use context menu interactions for marking solutions, managing settings, etc.Command Structure
Example fromapps/discord-bot/src/commands/mark-solution.ts:
Key Patterns
Event Handling
The bot listens to Discord events and processes them using services.Message Events
Fromapps/discord-bot/src/services/indexing.ts:
Working with Effect Services
Effect provides dependency injection and error handling.Discord Service
TheDiscord service wraps discord.js with Effect:
Database Service
TheDatabase service provides typed access to Convex:
Error Handling
Effect enables comprehensive error handling:Background Services
Services run continuously to handle tasks like indexing and auto-threading.Creating a Service
Example structure:Service Composition
Combine services with layers:Data Synchronization
The bot syncs Discord data to Convex.Syncing Servers
Fromapps/discord-bot/src/sync/server.ts:
Testing
Use Vitest with Effect’s testing utilities.Unit Tests
E2E Tests
Fromapps/bot-e2e/tests/smoke.test.ts:
Troubleshooting
Bot not responding to commands
- Check if the bot has the required permissions
- Verify commands are registered:
Rate limiting errors
Add delays between Discord API calls:Effect runtime errors
Ensure all services are provided:Next Steps
- Learn about Frontend Development
- Explore Database patterns
- Check Testing strategies