Becca Lyria
Becca Lyria (hereinafter the βApplicationβ) is an AI-powered Discord bot that provides an interactive text-based role-playing game experience through direct messages. The bot utilizes Anthropicβs Claude AI to create dynamic, personalized RPG adventures for users.
1. User Documentation
This section is for those interacting with a live instance of the Application.
Overview
Becca Lyria is a user-installable Discord bot that transforms your DMs into an immersive text-based RPG experience. Acting as a wise mage named Becca with a cold and calculating personality, the bot serves as your personal dungeon master, weaving interactive stories that adapt to your choices and actions.
Getting Started
- Installation: Add Becca Lyria to your Discord account
- Subscription: The bot requires an active subscription to use its features
- Start Playing: Use the
/start
command to begin your adventure
Available Commands
/start
- Start a new RPG scenario. Becca will create a fresh adventure and send it to your DMs/about
- Learn more about the bot, including version information and useful links/clear
- Clear your current adventure history to start fresh
How to Play
- Send Becca a
/start
command to begin a new adventure - Once the story begins in your DMs, simply respond naturally to continue the narrative
- The bot maintains conversation history (up to 20 messages) to provide context-aware responses
- Use
/clear
to reset your adventure history when you want to start over - The bot supports free-form text adventures - you can attempt any action you can imagine
Features
- AI-Powered Storytelling: Powered by Claude 3.5 Sonnet for rich, dynamic narratives
- Conversation Memory: Maintains context from recent messages for coherent storytelling
- Free-Form Gameplay: No restrictive multiple choice options - express your actions naturally
- Personalized Experience: The bot adapts to your playstyle and incorporates your Discord display name
- Privacy-Focused: All gameplay happens in private DMs
Subscription Model
Becca Lyria operates on a premium subscription model through Discordβs monetization system. Users must have an active subscription to access the botβs RPG features.
2. Technical Documentation
This section is for those interested in running their own instance of the Application.
Architecture Overview
Becca Lyria is built as a modern Discord bot using TypeScript and several key technologies:
Core Technologies:
- Node.js/TypeScript: Main runtime and development language
- Discord.js: Discord API interaction library
- Anthropic SDK: Integration with Claude AI models
- Fastify: Web server for health monitoring
- PNPM: Package management
AI Integration:
- Provider: Anthropic Claude (claude-3-5-sonnet-latest for conversations, claude-sonnet-4-20250514 for story starts)
- Context Management: Maintains up to 20 messages of conversation history
- Personality System: Configurable personality traits for consistent character behavior
Project Structure
src/βββ index.ts # Main entry point and Discord client setupβββ commands/ # Slash command definitionsβ βββ about.tsβ βββ clear.tsβ βββ start.tsβββ config/β βββ personality.ts # AI personality configurationβββ events/β βββ message.ts # Direct message event handlingβββ modules/ # Command implementation logicβ βββ about.tsβ βββ clear.tsβ βββ start.tsβββ server/β βββ serve.ts # Health monitoring web serverβββ utils/ # Utility functions βββ ai.ts # Anthropic client configuration βββ calculateCost.ts # Usage cost tracking βββ isSubscribed.ts # Subscription verification βββ logger.ts # Logging utility βββ replyToError.ts # Error handling
Environment Variables
The application requires several environment variables:
DISCORD_TOKEN
: Discord bot tokenAI_TOKEN
: Anthropic API keyLOG_TOKEN
: Logging service token (optional)
Key Features Implementation
Subscription System:
- Integrates with Discordβs premium features
- SKU ID:
1343347225698500744
- Entitlement checking for both interactions and messages
- Special bypass for bot owner (ID:
465650873650118659
)
Conversation Management:
- Fetches last 20 messages from DM channel
- Supports history clearing with special
<Clear History>
marker - Converts message history to Anthropicβs message format
- Maintains role context (user vs assistant)
Error Handling:
- Comprehensive error logging with custom logger
- Graceful error responses to users
- Unhandled rejection and exception catching
Cost Tracking:
- Monitors AI usage with token counting
- Calculates costs based on Anthropic pricing (input: $3/1M tokens, output: $15/1M tokens)
- Logs usage statistics per user
Development Setup
- Prerequisites: Node.js, PNPM
- Installation:
pnpm install
- Build:
pnpm run build
- Development: Configure environment variables in
dev.env
- Production: Configure environment variables in
prod.env
- Start:
pnpm start
(requires 1Password CLI for env injection)
Deployment Considerations
- Web server runs on port 5010 for health checks
- Requires Discord bot permissions for DMs and message content
- Needs stable Anthropic API access
- Logging integration with nhcarrigan logging service
3. Legal Documentation
This section is for expansions to our legal policies specific to the Application.
Data Processing
Your conversation history is transmitted to Anthropic AI for processing and response generation. The content of your messages may be retained by them for model improvement.
Subscription Model
Becca operates as a paid service with a $5/month subscription fee per Discord server. This subscription model ensures:
- Sustainable development and maintenance
- Priority support for subscribers
- Regular feature updates and improvements
- Infrastructure costs coverage
Service Availability
- Best-effort uptime with monitoring systems
- Planned maintenance notifications
- Support through designated Discord server
- Community-driven feedback and feature requests
4. Contributing Documentation
This section is for documentation related to contributing to the Applicationβs codebase.
Development Standards
Code Quality:
- TypeScript with strict configuration
- ESLint with @nhcarrigan/eslint-config
- Maximum function length limits enforced
- Comprehensive JSDoc documentation required
Testing:
- Vitest framework configured
- Istanbul coverage reporting
- Currently no tests implemented (placeholder exists)
Licensing:
- Licensed under Naomiβs Public License
- Copyright held by Naomi Carrigan
- See LICENSE.md for full terms
Contribution Process
- Issues: Report bugs and request features through GitHub issues
- Pull Requests: Fork, develop, and submit PRs for review
- Code Review: All changes require review before merging
- Guidelines: Follow established contributing guidelines
- Conduct: Adhere to Code of Conduct
Development Workflow
Commands:
pnpm run build
: Compile TypeScript to production JavaScriptpnpm run lint
: Run ESLint with zero warnings tolerancepnpm run test
: Run test suite (currently placeholder)pnpm start
: Start production build with environment injection
Architecture Patterns:
- Event-driven Discord bot architecture
- Modular command system with separate definition and implementation
- Utility-first approach for common functionality
- Separation of concerns between commands, events, and business logic
Contact Information
- Chat Server: http://chat.nhcarrigan.com
- Email: [email protected]
- Source Code: https://git.nhcarrigan.com/nhcarrigan/becca-lyria
- Documentation: https://docs.nhcarrigan.com/