🎭 Core Transformation: - Reframe project as AI companion bot with Kasane Teto personality - Focus on natural conversation, multimodal interaction, and character roleplay - Position video recording as one tool in AI toolkit rather than main feature 🏗️ Architecture Improvements: - Refactor messageCreate.js into modular command system (35 lines vs 310+) - Create dedicated videoRecording service with clean API - Implement commandHandler for extensible command routing - Add centralized configuration system (videoConfig.js) - Separate concerns: events, services, config, documentation 📚 Documentation Overhaul: - Consolidate scattered READMEs into organized docs/ directory - Create comprehensive documentation covering: * AI architecture and capabilities * Natural interaction patterns and personality * Setup guides for AI services and Docker deployment * Commands reference focused on conversational AI * Troubleshooting and development guidelines - Transform root README into compelling AI companion overview 🤖 AI-Ready Foundation: - Document integration points for: * Language models (GPT-4/Claude) for conversation * Vision models (GPT-4V/CLIP) for image analysis * Voice synthesis (ElevenLabs) for speaking * Memory systems for conversation continuity * Personality engine for character consistency 🔧 Technical Updates: - Integrate custom discord.js-selfbot-v13 submodule with enhanced functionality - Update package.json dependencies for AI and multimedia capabilities - Maintain Docker containerization with improved architecture - Add development and testing infrastructure 📖 New Documentation Structure: docs/ ├── README.md (documentation hub) ├── setup.md (installation & AI configuration) ├── interactions.md (how to chat with Teto) ├── ai-architecture.md (technical AI systems overview) ├── commands.md (natural language interactions) ├── personality.md (character understanding) ├── development.md (contributing guidelines) ├── troubleshooting.md (problem solving) └── [additional specialized guides] ✨ This update transforms the project from a simple recording bot into a foundation for an engaging AI companion that can naturally interact through text, voice, and visual content while maintaining authentic Kasane Teto personality traits.
6 KiB
Discord Teto Bot - Services Documentation
This directory contains the core services and business logic for the Discord Teto bot, separated from the event handling for better maintainability and testability.
Architecture Overview
The bot has been refactored into a modular architecture with the following components:
Services (/src/services/)
videoRecording.js
The main video recording service that handles all video recording functionality.
Key Features:
- Voice channel joining and leaving
- Video stream creation and management
- File output handling
- Recording state management
- Auto-stop functionality (30-second demo limit)
Main Methods:
startRecording({ client, voiceChannel, user, textChannel })- Starts recordingstopRecording(voiceChannelId, textChannel, message)- Stops recordinggetStatus()- Returns recording status and file informationisRecording(voiceChannelId)- Checks if channel is being recordedgetRecordingInfo(voiceChannelId)- Gets recording details
commandHandler.js
Handles all bot commands in a modular way, making it easy to add, remove, or modify commands.
Registered Commands:
dm_pickup- Responds to "teto" mentions in DMsstart_recording- Handles "xbox record that" commandstop_recording- Handles "stop recording" and "xbox stop" commandsstatus- Handles "teto status" commandhello- Handles "hello teto" messages
Key Methods:
processMessage(msg, context)- Processes incoming messages and executes matching commandsaddCommand(name, command)- Dynamically add new commandsremoveCommand(name)- Remove existing commandsgetAvailableCommands()- List all registered commands
Configuration (/src/config/)
videoConfig.js
Centralized configuration for all video recording settings.
Configuration Sections:
- File Paths: Output directories for container and host
- Recording Settings: Timeouts, delays, and limits
- Voice Settings: Discord voice connection parameters
- FFmpeg Options: Video and audio encoding settings
- Error Messages: Standardized error messages
- Success Messages: User-friendly feedback messages
- Status Templates: Formatted status report templates
Events (/src/events/)
messageCreate.js (Refactored)
Now focuses solely on message routing and basic logging. All command logic has been moved to the command handler.
Responsibilities:
- Message logging
- Bot message filtering
- Command routing to
commandHandler - Action logging
Benefits of the New Architecture
1. Separation of Concerns
- Event handling is separate from business logic
- Video recording logic is isolated in its own service
- Commands are modular and self-contained
2. Maintainability
- Easy to add new commands without touching event handlers
- Configuration is centralized and easy to modify
- Each service has a single responsibility
3. Testability
- Services can be unit tested independently
- Mock dependencies are easier to inject
- Command logic is isolated and testable
4. Reusability
- Video recording service can be used by multiple commands
- Command handler can be extended for different event types
- Configuration can be shared across services
5. Error Handling
- Centralized error messages and handling
- Better error isolation between services
- Consistent user feedback
Usage Examples
Adding a New Command
// In commandHandler.js
this.commands.set('new_command', {
trigger: (msg) => msg.content.toLowerCase() === 'my new command',
execute: async (msg, context) => {
msg.channel.send('Response to new command!');
return {
action: {
message: `New command executed by ${msg.author.tag}`,
channel: `#${msg.channel.name}`,
icon: "🆕",
}
};
}
});
Using the Video Recording Service
import videoRecordingService from './videoRecording.js';
// Start recording
const result = await videoRecordingService.startRecording({
client: discordClient,
voiceChannel: userVoiceChannel,
user: discordUser,
textChannel: messageChannel
});
// Check recording status
const status = videoRecordingService.getStatus();
console.log(`Active recordings: ${status.activeRecordings}`);
// Stop recording
await videoRecordingService.stopRecording(
voiceChannelId,
textChannel,
'Recording stopped manually'
);
Modifying Configuration
// In videoConfig.js
export const VIDEO_CONFIG = {
AUTO_STOP_TIMEOUT: 60_000, // Change to 60 seconds
MAX_RECORDING_DURATION: 600_000, // 10 minutes
// ... other settings
};
File Structure
src/
├── config/
│ └── videoConfig.js # Configuration constants
├── events/
│ └── messageCreate.js # Refactored event handler
└── services/
├── commandHandler.js # Command routing and execution
├── videoRecording.js # Video recording business logic
└── README.md # This documentation
Docker Integration
The video recording service is designed to work in a Docker environment:
- Container Output:
/tmp/output/(temporary storage) - Host Volume:
./output/(persistent storage via volume mount) - File Format: MKV (supports both audio and video)
- Processing: FFmpeg-based encoding
Future Improvements
- Database Integration: Store recording metadata
- User Permissions: Role-based command access
- Recording Quality Settings: Configurable video quality
- Multiple Format Support: MP4, WebM export options
- Recording Scheduling: Timed recordings
- Webhook Integration: External notifications
- Analytics: Usage statistics and monitoring
Contributing
When adding new features:
- Keep services focused on single responsibilities
- Add configuration to
videoConfig.jsrather than hardcoding - Use the command handler pattern for new commands
- Follow the existing error handling patterns
- Update this documentation