{"id":35788415,"url":"https://github.com/cxyfer/leetcode-daily-discord-bot","last_synced_at":"2026-02-20T02:12:34.690Z","repository":{"id":284413062,"uuid":"954863809","full_name":"cxyfer/leetcode-daily-discord-bot","owner":"cxyfer","description":"A modern Discord bot that automatically fetches and shares LeetCode daily challenges","archived":false,"fork":false,"pushed_at":"2026-01-22T06:25:38.000Z","size":1279,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-22T20:49:52.045Z","etag":null,"topics":["discord-bot","leetcode"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cxyfer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-25T18:24:46.000Z","updated_at":"2026-01-22T06:25:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"670d23f4-bf85-4723-b882-48b0542ba67b","html_url":"https://github.com/cxyfer/leetcode-daily-discord-bot","commit_stats":null,"previous_names":["cxyfer/leetcode-daily-discord-bot"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/cxyfer/leetcode-daily-discord-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxyfer%2Fleetcode-daily-discord-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxyfer%2Fleetcode-daily-discord-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxyfer%2Fleetcode-daily-discord-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxyfer%2Fleetcode-daily-discord-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cxyfer","download_url":"https://codeload.github.com/cxyfer/leetcode-daily-discord-bot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxyfer%2Fleetcode-daily-discord-bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29638789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T22:32:43.237Z","status":"online","status_checked_at":"2026-02-20T02:00:07.535Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["discord-bot","leetcode"],"created_at":"2026-01-07T07:26:07.063Z","updated_at":"2026-02-20T02:12:34.681Z","avatar_url":"https://github.com/cxyfer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\r\n\r\n# 🎯 LeetCode Daily Challenge Discord Bot\r\n\r\n*A modern Discord bot that automatically fetches and shares LeetCode daily challenges*\r\n\r\n[![Python](https://img.shields.io/badge/python-3.10+-blue.svg?style=flat-square\u0026logo=python)](https://www.python.org)\r\n[![Discord](https://img.shields.io/badge/Discord-bot-5865F2.svg?style=flat-square\u0026logo=discord)](https://discord.com/developers/docs/intro)\r\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)\r\n\r\n\u003c/div\u003e\r\n\r\n## ✨ Features\r\n\r\n- 🔄 **Automatic Daily Challenge**: Automatically retrieves and posts LeetCode daily challenges\r\n- ⏰ **Scheduled Delivery**: Configurable posting time for each server\r\n- 🎮 **Slash Commands**: Easy-to-use slash commands for manual control\r\n- 📊 **Rich Information**: Includes title, difficulty, link, tags, and more\r\n- 🌐 **Multi-server Support**: Independent settings for each Discord server\r\n- 🔔 **Custom Notifications**: Configurable role mentions and channels\r\n- 🌍 **Timezone Support**: Server-specific timezone settings\r\n- 📅 **Historical Challenges**: View past daily challenges by date\r\n- 🔍 **Problem Lookup**: Query single or multiple LeetCode problems with custom titles and messages\r\n- 📈 **Submission Tracking**: View recent accepted submissions for any user\r\n- 🤖 **AI-Powered Features**: Optional problem translation and inspiration (requires Gemini API key)\r\n- 🧭 **Similar Problem Search**: Find related problems via Gemini embeddings (requires index build)\r\n- 💾 **Smart Caching**: Efficient caching system for better performance\r\n\r\n## 🚀 Quick Start\r\n\r\n1. Clone the repository:\r\n   ```bash\r\n   git clone https://github.com/cxyfer/leetcode-daily-discord-bot.git\r\n   cd leetcode-daily-discord-bot\r\n   ```\r\n\r\n2. Configure your bot:\r\n   ```bash\r\n   # Copy and edit the configuration file\r\n   cp config.toml.example config.toml\r\n   # Edit config.toml with your settings\r\n   \r\n   # Alternative: Use environment variables (.env)\r\n   cp .env.example .env\r\n   # Edit .env with your Discord bot token\r\n   ```\r\n\r\n3. Run database migration (if upgrading from older version):\r\n   ```bash\r\n   # Migrate server settings from settings.db to data.db\r\n   sqlite3 data/data.db \u003c data/migrate_settings.sql\r\n   ```\r\n\r\n4. Run the bot:\r\n   ```bash\r\n   uv run bot.py\r\n   ```\r\n\r\n## 🐳 Docker Image\r\n\r\nOfficial GHCR image: `ghcr.io/cxyfer/leetcode-daily-discord-bot`  \r\nIf you are using a fork, replace it with `ghcr.io/\u003cyour-owner\u003e/\u003cyour-repo\u003e`.\r\n\r\n### Docker Run (config.toml)\r\n\r\n```bash\r\nmkdir -p data logs\r\ndocker run -d --name leetcode-daily-discord-bot \\\r\n  --restart unless-stopped \\\r\n  -v /path/to/config.toml:/app/config.toml:ro \\\r\n  -v /path/to/data:/app/data \\\r\n  -v /path/to/logs:/app/logs \\\r\n  ghcr.io/cxyfer/leetcode-daily-discord-bot:latest\r\n```\r\n\r\n### Docker Run (.env)\r\n\r\n```bash\r\nmkdir -p data logs\r\ndocker run -d --name leetcode-daily-discord-bot \\\r\n  --restart unless-stopped \\\r\n  -v /path/to/.env:/app/.env:ro \\\r\n  -v /path/to/data:/app/data \\\r\n  -v /path/to/logs:/app/logs \\\r\n  ghcr.io/cxyfer/leetcode-daily-discord-bot:latest\r\n```\r\n\r\n- `/app/data` contains `data.db`; keep it mapped to persist settings and cache.\r\n- `config.toml` is recommended; `.env` is for backward compatibility.\r\n- Use `:v1.0.0` to pin a specific release; `:latest` tracks the newest image.\r\n\r\n## 🛠️ Configuration\r\n\r\n### Configuration Methods\r\n\r\nThe bot supports two configuration methods:\r\n\r\n#### 1. TOML Configuration (Recommended)\r\n\r\nCreate a `config.toml` file from the example:\r\n\r\n```toml\r\n[discord]\r\ntoken = \"your_discord_bot_token_here\"\r\n\r\n[llm.gemini]\r\napi_key = \"your_google_gemini_api_key_here\"  # Optional, for AI features\r\n\r\n[schedule]\r\npost_time = \"00:00\"  # Default posting time\r\ntimezone = \"UTC\"     # Default timezone\r\n```\r\n\r\nSee `config.toml.example` for all available options.\r\n\r\n#### 2. Environment Variables\r\n\r\nFor backward compatibility, you can use a `.env` file:\r\n\r\n```bash\r\nDISCORD_TOKEN=your_bot_token_here\r\nGOOGLE_GEMINI_API_KEY=your_gemini_api_key_here  # Optional\r\nGOOGLE_API_KEY=your_gemini_api_key_here         # Optional alternative\r\nGEMINI_API_KEY=your_gemini_api_key_here         # Optional alternative\r\nPOST_TIME=00:00  # Optional\r\nTIMEZONE=UTC     # Optional\r\n```\r\n\r\n**Note**: Environment variables take precedence over `config.toml` settings.\r\n\r\n### Required Bot Permissions\r\n- `Send Messages`\r\n- `Embed Links`\r\n- `Use Slash Commands`\r\n\r\n### Required Intents\r\n- `Message Content` - Receive message content\r\n  - Note: When the bot joins more than 100 servers, this permission needs to be verified and approved by Discord\r\n\r\n## 📝 Usage\r\n\r\n### Slash Commands\r\n\r\n| Command | Description | Required Permissions |\r\n|---------|-------------|---------------------|\r\n| `/daily [date] [public]` | Display LeetCode.com (LCUS) daily challenge\u003cbr\u003e• Optional: YYYY-MM-DD for historical challenges\u003cbr\u003e• Optional: `public` - Show response publicly (default: private)\u003cbr\u003e• Note: Historical data available from April 2020 onwards | None |\r\n| `/daily_cn [date] [public]` | Display LeetCode.cn (LCCN) daily challenge\u003cbr\u003e• Optional: YYYY-MM-DD for historical challenges\u003cbr\u003e• Optional: `public` - Show response publicly (default: private) | None |\r\n| `/problem \u003cproblem_ids\u003e [source] [domain] [public] [message] [title]` | Query one or multiple problems\u003cbr\u003e• `problem_ids`: Single ID (e.g., `1`) or comma-separated IDs (e.g., `1,2,3`)\u003cbr\u003e• Supports `source:id` format (e.g., `atcoder:abc001_a`, `leetcode:1`)\u003cbr\u003e• `source`: Problem source - `leetcode` (default) or `atcoder`\u003cbr\u003e• `domain`: LeetCode domain - `com` or `cn` (default: `com`)\u003cbr\u003e• `public`: Show response publicly (default: private)\u003cbr\u003e• `message`: Optional personal message/note (max 500 chars)\u003cbr\u003e• `title`: Custom title for multi-problem mode (max 100 chars)\u003cbr\u003e• Note: Supports up to 10 problems per query | None |\r\n| `/recent \u003cusername\u003e [limit] [public]` | View recent accepted submissions for a user\u003cbr\u003e• `username`: LeetCode username (LCUS only)\u003cbr\u003e• `limit`: Number of submissions (1-50, default: 20)\u003cbr\u003e• `public`: Show response publicly (default: private) | None |\r\n| `/similar \u003cquery\u003e [top_k] [source] [public]` | Find similar problems from the embedding index\u003cbr\u003e• `query`: Problem description or keywords\u003cbr\u003e• `top_k`: Number of results (default: 5)\u003cbr\u003e• `source`: Problem source (default: leetcode)\u003cbr\u003e• `public`: Show response publicly (default: private) | None |\r\n| `/set_channel` | Set notification channel for daily challenges | Manage Channels |\r\n| `/set_role` | Set role to mention with daily challenges | Manage Roles |\r\n| `/set_post_time` | Set posting time (HH:MM format) | Manage Guild |\r\n| `/set_timezone` | Set server timezone for scheduling | Manage Guild |\r\n| `/show_settings` | Display current server settings | None |\r\n| `/remove_channel` | Remove channel settings | Manage Channels |\r\n\r\n### Command Examples\r\n\r\n#### Daily Challenge Commands\r\n```\r\n/daily                    # Get today's LeetCode.com challenge (private)\r\n/daily public:true        # Get today's challenge and show response publicly\r\n/daily date:2024-01-15    # Get historical challenge from Jan 15, 2024\r\n```\r\n\r\n#### Problem Lookup\r\n```\r\n# Single problem lookup\r\n/problem problem_ids:1                    # Get Two Sum problem from LeetCode.com (private)\r\n/problem problem_ids:1 public:true        # Get Two Sum problem publicly\r\n\r\n# Multiple problems lookup\r\n/problem problem_ids:1,2,3                # Get multiple problems with overview\r\n/problem problem_ids:1,2,3 title:Dynamic Programming Practice  # Custom title\r\n/problem problem_ids:1,2,3 message:Today's study plan         # With personal note\r\n/problem problem_ids:1,2,3 title:Weekly Contest Problems message:Need to practice these  # Both title and message\r\n\r\n# Multi-problem with domain selection\r\n/problem problem_ids:1,2,3 domain:cn      # Query from LeetCode.cn\r\n\r\n# AtCoder problems (auto-detected or explicit source)\r\n/problem problem_ids:abc001_a             # Auto-detect AtCoder from ID pattern\r\n/problem problem_ids:atcoder:abc001_a     # Explicit source:id format\r\n/problem problem_ids:abc001_a source:atcoder  # Explicit source parameter\r\n\r\n# Mixed sources\r\n/problem problem_ids:1,abc001_a,leetcode:15   # Mix LeetCode and AtCoder\r\n```\r\n\r\n#### Recent Submissions\r\n```\r\n/recent username:alice              # View 20 recent submissions (private)\r\n/recent username:alice limit:50     # View 50 recent submissions\r\n/recent username:alice limit:50 public:true  # View 50 submissions publicly\r\n```\r\n\r\n#### Similar Problem Search\r\n```\r\n/similar query:\"array sorting\"                # Find related problems (private)\r\n/similar query:\"two pointers\" top_k:3         # Limit results to 3\r\n/similar query:\"dp with knapsack\" public:true # Show results publicly\r\n```\r\n\r\n\u003e Note: `/similar` requires an embedding index. Build it with `uv run python embedding_cli.py --build`.\r\n\r\n#### Server Configuration\r\n```\r\n/set_channel              # Set current channel for daily notifications\r\n/set_role                 # Configure role to ping\r\n/set_post_time time:08:00 # Set daily post time to 8:00 AM\r\n/set_timezone timezone:America/New_York  # Set timezone\r\n/show_settings            # View current configuration\r\n```\r\n\r\n### Server Configuration Steps\r\n\r\n1. Set up notification channel using `/set_channel` (Required)\r\n2. Configure role mentions with `/set_role` (Optional)\r\n3. Set posting time and timezone (Optional)\r\n4. Verify settings with `/show_settings`\r\n\r\n### Embedding CLI\r\n\r\nUse the CLI to build and maintain the embedding index for `/similar`:\r\n\r\n```\r\nuv run python embedding_cli.py --stats\r\nuv run python embedding_cli.py --build --dry-run\r\nuv run python embedding_cli.py --build --dry-run --source codeforces\r\nuv run python embedding_cli.py --build --dry-run --source all\r\nuv run python embedding_cli.py --build\r\nuv run python embedding_cli.py --rebuild\r\nuv run python embedding_cli.py --query \"two sum\"\r\n```\r\n\r\n### LeetCode CLI (Missing Content)\r\n\r\nFill missing problem statements (Algorithms, free only):\r\n\r\n```\r\nuv run python leetcode.py --missing-content-stats\r\nuv run python leetcode.py --fill-missing-content\r\nuv run python leetcode.py --fill-missing-content --fill-missing-content-workers 10\r\n```\r\n\r\n### AtCoder CLI\r\n\r\nFetch AtCoder contests and problem content:\r\n\r\n```\r\nuv run python atcoder.py --sync-kenkoooo\r\nuv run python atcoder.py --fetch-all --resume\r\nuv run python atcoder.py --contest abc001\r\nuv run python atcoder.py --status\r\n```\r\n\r\n### Codeforces CLI\r\n\r\nFetch Codeforces contests and problem content:\r\n\r\n```\r\nuv run python codeforces.py --sync-problemset\r\nuv run python codeforces.py --fetch-all --resume\r\nuv run python codeforces.py --contest 2082\r\nuv run python codeforces.py --status\r\nuv run python codeforces.py --fill-missing-content\r\nuv run python codeforces.py --missing-content-stats\r\nuv run python codeforces.py --reprocess-content\r\n```\r\n\r\nOptional flags: `--include-gym`, `--rate-limit`, `--data-dir`, `--db-path`.\r\n\r\n### Multi-Problem Features\r\n\r\nThe `/problem` command supports querying multiple problems at once with enhanced customization:\r\n\r\n#### Overview Mode\r\nWhen querying multiple problems, the bot displays:\r\n- **Grouped Display**: Problems organized in groups of 5 per field\r\n- **Problem Links**: Direct clickable links to LeetCode problems\r\n- **Difficulty Indicators**: Color-coded emojis (🟢 Easy, 🟡 Medium, 🔴 Hard)\r\n- **Problem Stats**: Rating and acceptance rate when available\r\n- **Interactive Buttons**: Click numbered buttons to view detailed problem information\r\n\r\n#### Customization Options\r\n- **Custom Title**: Replace the default title with your own (max 100 characters)\r\n- **Personal Message**: Add notes, study plans, or context (max 500 characters)\r\n- **User Attribution**: Shows your name and avatar when title or message is provided\r\n\r\n#### Example Use Cases\r\n```\r\n# Study plan organization\r\n/problem problem_ids:70,322,518 title:📚 Dynamic Programming Week 1 message:Focus on bottom-up approach\r\n\r\n# Contest preparation\r\n/problem problem_ids:1,15,42 title:🏆 Weekly Contest #420 Prep message:Practice these before Sunday\r\n\r\n# Topic-based practice\r\n/problem problem_ids:104,226,543 title:🌳 Binary Tree Fundamentals message:Master tree traversal first\r\n```\r\n\r\n## 🗺️ Development Roadmap\r\n\r\n- [x] 🎮 **Enhanced Command Interface**\r\n  - [x] Add slash command prompts\r\n  - [x] Reply in the same channel where slash commands are used\r\n  - [x] Add `/problem` command for querying problems by ID\r\n  - [x] Enhanced `/problem` command with multi-problem support and customization\r\n  - [x] Add `/recent` command for viewing user submissions\r\n  - [x] Support historical daily challenges with date parameter\r\n- [x] ⚙️ **Advanced Configuration System**\r\n  - [x] Allow admin users to set the configuration\r\n    - [x] Set the channel to post the daily challenge\r\n    - [x] Set the posting time and timezone\r\n    - [x] Set the role to mention\r\n    - [ ] Set customizable message templates\r\n    - [ ] Integrate the existing excessive setup instructions\r\n    - [ ] More flexible notification settings\r\n- [x] 🌐 **Multi-server Infrastructure**\r\n  - [x] Support server-specific configurations\r\n- [x] 📝 **Code Optimization**\r\n  - [x] Implement improved runtime logging\r\n  - [ ] Implement modular architecture\r\n  - [x] Add comprehensive documentation\r\n- [x] 🇨🇳 **LeetCode.cn Integration**\r\n  - [x] Add slash command `/daily_cn` for LeetCode.cn daily challenge\r\n  - [ ] Implement separate scheduler for LeetCode.cn challenges\r\n- [ ] 🗄️ **Database Integration**\r\n  - [x] Store and query problem information in database\r\n  - [x] Enable historical daily challenge lookup\r\n- [x] 🔍 **Large Language Model Integration**\r\n  - [x] Integrate LLM to generate problem translation and inspiration\r\n  - [x] Cache LLM results to improve performance\r\n- [x] 📊 **User Engagement Features**\r\n  - [x] Track submission records of specific users\r\n  - [x] Interactive navigation for viewing multiple submissions\r\n  - [x] Paginated display with clean UI\r\n  - [ ] Allow users to configure tracked LeetCode accounts\r\n  - [ ] Implement server-wide submission leaderboards\r\n- [ ] 🐳 **Containerization Support**\r\n  - [ ] Add Docker compose file and image\r\n- [ ] 🌍 **Internationalization**\r\n  - [ ] Support multiple display languages\r\n\r\n## 🗞️ Release Notes\r\n\r\nSee [CHANGELOG.md](CHANGELOG.md) for versioned release notes and history.\r\n\r\n## 🛠️ Development\r\n\r\n### Setup Development Environment\r\n\r\nThis project uses [uv](https://github.com/astral-sh/uv) for dependency management. To set up the development environment with all dev tools:\r\n\r\n```bash\r\nuv sync --extra dev\r\n```\r\n\r\n### Code Quality and Testing\r\n\r\nWe use `ruff` for linting and formatting, and `pytest` for testing.\r\n\r\n#### Linting and Formatting\r\n```bash\r\n# Check for linting issues\r\nuv run ruff check .\r\n\r\n# Fix linting issues automatically\r\nuv run ruff check --fix .\r\n\r\n# Format code\r\nuv run ruff format .\r\n```\r\n\r\n#### Running Tests\r\n```bash\r\n# Run all tests with coverage report\r\nuv run pytest\r\n\r\n# Run specific test file\r\nuv run pytest tests/test_source_detector.py\r\n```\r\n\r\n## 🤝 Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\r\n\r\n## 📦 Dependencies\r\n\r\n- [discord.py](https://pypi.org/project/discord.py/) - Discord bot framework\r\n- [tomli](https://pypi.org/project/tomli/) - TOML parsing for Python \u003c 3.11\r\n- [python-dotenv](https://pypi.org/project/python-dotenv/) - Environment variable management\r\n- [requests](https://pypi.org/project/requests/) - HTTP library for API calls\r\n- [pytz](https://pypi.org/project/pytz/) - Timezone handling\r\n- [beautifulsoup4](https://pypi.org/project/beautifulsoup4/) - HTML parsing\r\n- [colorlog](https://pypi.org/project/colorlog/) - Colored logging output\r\n- [google-genai](https://pypi.org/project/google-genai/) - Google Gemini SDK\r\n- [aiohttp](https://pypi.org/project/aiohttp/) - Asynchronous HTTP client/server\r\n\r\n## 📄 License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxyfer%2Fleetcode-daily-discord-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcxyfer%2Fleetcode-daily-discord-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxyfer%2Fleetcode-daily-discord-bot/lists"}