A Discord bot that automatically tracks and displays Wordle game statistics for guild members, featuring real-time score capture, historical data scraping, and interactive leaderboards with personal performance analytics.
- 🎯 Real-time Score Capture: Automatically monitors and parses Wordle results posted by the Wordle App Bot
- 📊 Interactive Leaderboards: View weekly, monthly, and all-time rankings with custom scoring algorithms
- 📈 Personal Statistics: Track individual performance metrics including solve rates, streaks, and average guesses
- 🔄 Historical Backfill: Admin command to scrape past channel messages and populate the database
- 👥 User Synchronization: Automatically syncs Discord guild members to the database
- Runtime: Node.js with CommonJS modules
- Discord Integration: discord.js v14.24.2
- Database: SQLite with Prisma ORM v6.18.0
- Development: ESLint, TypeScript definitions, nodemon
- Node.js (v16 or higher recommended)
- A Discord bot token from the Discord Developer Portal
- Discord Developer Mode enabled (for obtaining IDs)
-
Clone the repository:
git clone https://github.com/LennyPK/discord-app-rcr.git cd discord-app-rcr -
Install dependencies:
npm install
-
Set up the database:
npx prisma generate npx prisma migrate dev
Create a .env file in the project root with the following variables:
# Discord Bot Configuration
DISCORD_TOKEN=your-bot-token-here
CLIENT_ID=your-client-id-here
GUILD_ID=your-guild-id-here
# Database Configuration
DATABASE_URL=file:./prisma/dev.db
# Wordle Bot Configuration
WORDLE_APP_ID=wordle_bot_user_id_here- DISCORD_TOKEN: Bot token from Discord Developer Portal → Your Application → Bot → Token
- CLIENT_ID: Application ID from Discord Developer Portal → Your Application → General Information
- GUILD_ID: Right-click your Discord server → Copy Server ID (requires Developer Mode)
- WORDLE_APP_ID: Right-click the Wordle App Bot → Copy User ID
Development mode (with auto-restart):
npm run devProduction mode:
npm startBefore first use, register slash commands with Discord:
node src/register-commands.js/wordle_leaderboard [type]- Display weekly, monthly, or all-time rankings/wordle_stats- View your personal Wordle statistics and performance metrics/wordle_init [range] [verbose]- Admin command to backfill historical Wordle data/update_members [verbose]- Sync Discord guild members to the database
The bot monitors messages from a designated Wordle App Bot and automatically captures scores when daily results are posted. Scores are parsed using regex patterns to extract user mentions and guess counts, then stored in a SQLite database with a composite unique key ensuring one score per user per day.
The scoring algorithm balances skill metrics (solve rate and guess efficiency) with participation incentives, calculating composite scores for leaderboard rankings.
The bot uses two primary models:
- User: Stores Discord user information (ID, username, display names)
- Wordle: Tracks individual game results (date, score, solved status) with a foreign key to User
src/
├── index.js # Bot entry point and initialization
├── prisma-client.js # Prisma client singleton
├── register-commands.js # Command registration utility
├── commands/
│ ├── wordle/ # Wordle tracking commands
│ └── utility/ # Utility commands
└── messages/
└── wordle/ # Message handlers for score capture