Skip to content

feat: add Discord bot integration for streak notifications#1337

Open
VIDYANKSHINI wants to merge 4 commits into
Priyanshu-byte-coder:mainfrom
VIDYANKSHINI:feat/discord-notifications
Open

feat: add Discord bot integration for streak notifications#1337
VIDYANKSHINI wants to merge 4 commits into
Priyanshu-byte-coder:mainfrom
VIDYANKSHINI:feat/discord-notifications

Conversation

@VIDYANKSHINI
Copy link
Copy Markdown
Contributor

Summary

This PR implements the Discord bot integration for streak notifications. It allows users to connect a Discord Webhook URL in their settings and select their local timezone. A background cron job checks hourly and sends a "streak at risk" notification at 8 PM in the user's local timezone if they haven't committed that day. It also sends milestone alerts and a weekly coding summary on Sundays.

Closes #1062

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / code cleanup

Changes Made

  • Added discord_webhook_url, timezone, and last_discord_notification_at columns to the users table.
  • Added a "Discord Integration" section in src/app/dashboard/settings/page.tsx with a Webhook input, Timezone selector, and a "Test Notification" button.
  • Created a utility src/lib/discord.ts to format and send rich Discord Embed messages.
  • Created /api/user/settings/discord-test endpoint for sending test webhooks.
  • Added /api/notifications/discord-sync endpoint and an hourly cron job in vercel.json to evaluate local timezones and trigger daily/weekly notifications.
  • Updated src/app/api/user/settings/route.ts to handle Discord settings updates.

How to Test

Steps for the reviewer to verify this works:

  1. Create a Discord Webhook URL in your test server.
  2. Go to Settings, scroll down to Discord Integration.
  3. Paste the Webhook URL and select your timezone, then click Save Discord Settings.
  4. Click Test Notification and verify that a test embed appears in your Discord channel.
  5. (Optional) Run the local environment and manually trigger the /api/notifications/discord-sync endpoint with a valid CRON_SECRET header to test streak at-risk and milestone notifications.

Checklist

  • Linked issue in summary
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Self-reviewed the diff
  • Added/updated tests if applicable

Copilot AI review requested due to automatic review settings May 27, 2026 18:25
@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

@VIDYANKSHINI is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature labels May 27, 2026
@github-actions
Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

Thanks @VIDYANKSHINI for the Discord integration! The code itself looks solid (Discord webhook lib, settings UI, Supabase migration). However, there's one critical issue:

The cron schedule "0 * * * *" (hourly) will break deployment on Vercel Hobby plan.

Vercel Hobby plan only allows cron jobs with daily or less frequent schedules (0 0 * * *). An hourly cron will cause a deployment error.

Please change the Discord sync cron to:

{ "path": "/api/notifications/discord-sync", "schedule": "0 0 * * *" }

Once you update this, we can merge!

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @VIDYANKSHINI! The Discord streak notification feature is well-implemented! One blocker: the vercel.json cron uses 0 * * * * (hourly) but the project is on Vercel's Hobby plan which only supports daily or less-frequent crons. Please change it to daily: 0 20 * * * (8 PM UTC daily) or similar. Thanks!

@VIDYANKSHINI VIDYANKSHINI force-pushed the feat/discord-notifications branch from 2517d8f to a9a13da Compare May 28, 2026 12:18
Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has 6 merge conflicts with current main and needs a rebase. Additionally, please check any cron schedules added are Hobby-plan compatible (daily 0 0 * * * or weekly, not hourly).

@VIDYANKSHINI VIDYANKSHINI force-pushed the feat/discord-notifications branch from a9a13da to 2e37355 Compare May 28, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add Discord bot integration for streak notifications

2 participants