A Discord bot for managing and scheduling tutoring sessions. Sprechi handles student verification, session scheduling, queue management, and ephemeral voice channel creation for tutoring sessions.
- Student Verification: Token-based verification system for authenticating students
- Queue Management: Automated queue system for students waiting for help
- Session Scheduling: Schedule and manage tutoring sessions with auto-lock functionality
- Voice Rooms: Dynamic voice channel creation for tutor-student interactions
- Statistics: Comprehensive server and session statistics
- DM Support: Students can verify and receive notifications via direct messages
- Node.js >= 24.0.0
- pnpm >= 10.24.0
- PostgreSQL database
- Discord Bot Token
-
Clone the repository
git clone https://github.com/tudalgo/Sprechi.git cd Sprechi -
Install dependencies
pnpm install
-
Configure environment variables
Create a
.envfile in the root directory:# Discord DISCORD_TOKEN=your_discord_bot_token # Database DATABASE_URL=postgresql://user:password@localhost:5432/sprechi # Encryption (for token generation) ENCRYPTION_KEY=your_secret_encryption_key # Environment NODE_ENV=development
-
Initialize the database
pnpm db:generate pnpm db:migrate
-
Generate verification tokens (if needed)
pnpm generate-tokens
Start the development server with hot reload:
pnpm devThis runs the bot with debug logging enabled and automatic restart on file changes.
pnpm dev- Start development server with hot reloadpnpm build- Compile TypeScript to JavaScriptpnpm start- Run the production buildpnpm preview- Run production build with dev environment variablespnpm lint- Run ESLintpnpm lint:fix- Fix ESLint errors automaticallypnpm typecheck- Run TypeScript type checkingpnpm test- Run tests in watch modepnpm test:coverage- Run tests with coverage reportpnpm db:generate- Generate database migration filespnpm db:migrate- Apply database migrations
The project uses Vitest for testing with comprehensive coverage requirements.
# Run tests in watch mode
pnpm test
# Run tests with coverage
pnpm test:coverage
# Run tests with coverage UI
pnpm test:coverage:uiTest files follow the same structure as source files, mirroring the src/ directory in tests/.
Build and run the bot using Docker:
# Build the image
docker build -t sprechi-v2 .
# Run the container
docker run -d \
--name sprechi \
-e DISCORD_TOKEN=your_token \
-e DATABASE_URL=your_db_url \
sprechi-v2Or use Docker Compose:
docker-compose up -dsprechi-v2/
├── src/
│ ├── commands/ # Discord slash commands
│ │ ├── admin/ # Admin-only commands
│ │ ├── queue/ # Student queue commands
│ │ ├── tutor/ # Tutor commands
│ │ └── verify.ts # Verification command
│ ├── managers/ # Business logic layer
│ │ ├── QueueManager.ts
│ │ ├── RoomManager.ts
│ │ ├── SessionManager.ts
│ │ ├── UserManager.ts
│ │ └── ...
│ ├── events/ # Discord event handlers
│ ├── db/ # Database schema and configuration
│ ├── utils/ # Utility functions
│ └── main.ts # Application entry point
├── tests/ # Test files (mirrors src structure)
├── .github/workflows/ # CI/CD workflows
└── drizzle/ # Database migrations
- Commands: Handle Discord interactions and delegate to Managers
- Managers: Contain all business logic and database operations
- Dependency Injection: Managers are injected into Commands/Events via constructors
- Type Safety: Strict TypeScript with Drizzle ORM for type-safe database queries
- Follow the existing code style and conventions
- Run
pnpm lint:fixbefore committing - Add tests for new features
- Update documentation as needed
- Keep business logic in Managers, not Commands
- Type Safety: Avoid
any, use explicit types orunknownwith type guards - Error Handling: Use custom error classes from the
errors/directory - Testing: All new code must include corresponding tests
- Logging: Use the logger utility (
src/utils/logger.ts)
This project is licensed under the AGPL-3.0-only License - see the LICENSE file for details.
- Framework: DiscordX (Discord.js wrapper with decorators)
- Database: Drizzle ORM with PostgreSQL
- Runtime: Node.js with TypeScript
- Package Manager: pnpm
- Testing: Vitest
- Container: Docker with multi-stage builds
For detailed architecture information and development guidelines, see agents.md.