Automatically tracks your daily LeetCode grind and posts it to Discord, every night, no PC needed.
- What It Does
- How It Works
- Screenshots
- Tracking Window
- Setup Guide
- Project Structure
- Customization
- Cookie Refresh
- Troubleshooting
- FAQ
- Contributing
- Security Notes
- Inspiration
Every day at 10:15 PM IST, this bot wakes up on GitHub's servers and:
- β Fetches all LeetCode problems you solved that day
- π¬ Posts them directly to your Discord channel
- π€ Requires zero input from you, PC can be completely off
Today (3 problems):
1) https://leetcode.com/problems/find-unique-binary-string
2) https://leetcode.com/problems/find-the-smallest-balanced-index
3) https://leetcode.com/problems/minimum-operations-to-sort-a-string
If you didn't solve anything, it posts:
No problems solved today
cron-job.org (10:15 PM IST)
β
βΌ
GitHub Actions triggered via API
β
βΌ
send.py runs on GitHub's servers
β
βΌ
LeetCode GraphQL API queried
(authenticated with session cookies)
β
βΌ
Accepted submissions from last 16 hours filtered
β
βΌ
Discord Webhook β message posted
Why session cookies? LeetCode blocks unauthenticated requests from cloud server IPs (like GitHub's). Using your browser session cookies authenticates the request and bypasses this block.
Why cron-job.org? GitHub Actions' built-in cron scheduler can delay by up to 60 minutes on free accounts. cron-job.org triggers the workflow via GitHub's API at the exact time every night.
The bot captures problems solved between 6:15 AM β 10:15 PM IST daily.
Late night solves (after 10:15 PM) won't be included, keeping your daily log clean and honest.
Your cookies authenticate the request so GitHub's servers aren't blocked by LeetCode.
- Go to leetcode.com and log in
- Press
F12β Application tab β Cookies βhttps://leetcode.com - Find and copy these two values:
LEETCODE_SESSIONcsrftoken
- Open your Discord server β right-click your channel β Edit Channel
- Go to Integrations β Webhooks β New Webhook
- Give it a name (e.g.
LeetCode Bot) and copy the webhook URL
Go to your repo β Settings β Secrets and variables β Actions β New repository secret
| Secret | Value |
|---|---|
LEETCODE_USERNAME |
Your LeetCode username |
LEETCODE_SESSION |
Cookie from Step 1 |
LEETCODE_CSRF |
csrftoken from Step 1 |
DISCORD_WEBHOOK |
Webhook URL from Step 2 |
Push the code to your repo. Then continue to Step 5 for reliable timing.
GitHub Actions cron can delay by up to 1 hour. Use cron-job.org to trigger it exactly on time.
- Sign up free at cron-job.org
- Create a new cronjob with:
- URL:
https://api.github.com/repos/YOUR_USERNAME/leetcode-discord-reporter/actions/workflows/YOUR_WORKFLOW_ID/dispatches - Schedule: 10:15 PM IST (16:45 UTC)
- Method: POST
- Headers:
Authorizationβtoken YOUR_GITHUB_TOKENAcceptβapplication/vnd.github.v3+json
- Body:
{"ref":"main"}
- URL:
- Save and test
β οΈ To get your Workflow ID, open this URL in your browser:https://api.github.com/repos/YOUR_USERNAME/leetcode-discord-reporter/actions/workflows
Your bot will now post every night automatically. No PC needed.
leetcode-discord-reporter/
βββ assets/
β βββ discord-screenshot.png # Discord bot output preview
βββ send.py # Core script β fetches & posts submissions
βββ LICENSE # MIT License
βββ README.md # This file
βββ .github/
βββ workflows/
βββ daily.yml # Triggered by cron-job.org every night at 10:15 PM IST
Update the schedule in your cron-job.org dashboard to your preferred time.
Edit send.py:
if now - sub_time < timedelta(hours=16): # tracks from 6:15 AM ISTIncrease or decrease the hours as needed.
Edit the limit in send.py:
"variables": {"username": username, "limit": 10}Increase if you solve more than 10 problems a day.
LeetCode session cookies expire. When the bot stops working:
- Log in to leetcode.com β
F12β Application β Cookies - Copy fresh
LEETCODE_SESSIONandcsrftokenvalues - Update them in GitHub β Settings β Secrets
| Problem | Cause | Fix |
|---|---|---|
No problems solved today but you did solve |
Cookies expired | Refresh LEETCODE_SESSION and csrftoken in GitHub Secrets |
KeyError: LEETCODE_SESSION |
Secret not added to yaml env | Add secret name to env block in daily.yml |
Q: Does my PC need to be on? No. Everything runs on GitHub's servers triggered by cron-job.org.
Q: Will it work if I don't solve anything?
Yes. It posts No problems solved today so you still get a daily reminder.
Q: How long do cookies last? Around 2 weeks. You'll need to refresh them when the bot stops working.
Q: Can I use this for Codeforces too? Not currently. Only LeetCode is supported.
Q: Is my data safe? Yes. All sensitive values are stored as GitHub Secrets and never exposed in code or logs.
Q: What if I solve more than 10 problems in a day?
Increase the limit value in send.py from 10 to a higher number.
Contributions are welcome! If you have ideas to improve this:
- Fork the repo
- Create a new branch:
git checkout -b feature/your-feature - Make your changes
- Commit:
git commit -m "Add your feature" - Push:
git push origin feature/your-feature - Open a Pull Request
- Add Codeforces support
- Add problem difficulty in the Discord message
- Add weekly summary report
- Add streak tracking
- β All sensitive values are stored as GitHub Secrets, never in code
β οΈ If your Discord webhook URL leaks, regenerate it immediately:Discord β Channel Settings β Integrations β Webhooks β Regenerate URLβ οΈ Never commit cookies directly into your repoβ οΈ Never share your GitHub Personal Access Token publicly
In class one day, our sir mentioned a student from another campus who had built something really cool, a bot that sent daily solved problem links to the college Discord server with a single command. Sir was genuinely impressed, said he only found out about it a few days later.
That story stayed with me. I took that same idea and pushed it a step further, no button, no local PC. Mine just runs automatically every night at 10:15 PM and posts on its own, whether my PC is on or not.
Respect to that guy for the inspiration. π
Built with πͺ ig, to keep the grind accountable...
