Fix Discord double-ping when autodraft fires after manual pick #47

Merged
chrisp merged 1 commit from fix/discord-autodraft-double-ping into main 2026-05-23 03:46:49 +00:00
Owner

Summary

  • `notifyPickMadeOnDiscord` was re-reading `currentPickNumber` from the DB to determine who is "on the clock". When a manual pick triggered an immediate autodraft chain, the DB had already advanced past the chained pick by the time both notifications fired — so both Discord messages showed the same next-up person, pinging them twice.
  • Fix: pass `nextPickNumber` (the pick immediately after the one being announced, before any autodraft chain) as an explicit param. Each announcement now shows the correct next drafter for that specific pick.
  • Removes a DB `seasons.findFirst` round-trip that fired on every pick announcement.

Test plan

  • Confirm the existing 14 unit tests in `draft-discord.server.test.ts` pass
  • In a local draft: set up a team with autodraft enabled and trigger a manual pick that causes them to immediately autodraft — confirm Discord shows two separate "on the clock" names rather than the same person twice
  • Confirm the final announcement (the autodraft pick) still correctly pings the actual next human drafter

🤖 Generated with Claude Code

## Summary - \`notifyPickMadeOnDiscord\` was re-reading \`currentPickNumber\` from the DB to determine who is "on the clock". When a manual pick triggered an immediate autodraft chain, the DB had already advanced past the chained pick by the time both notifications fired — so both Discord messages showed the same next-up person, pinging them twice. - Fix: pass \`nextPickNumber\` (the pick immediately after the one being announced, before any autodraft chain) as an explicit param. Each announcement now shows the correct next drafter for that specific pick. - Removes a DB \`seasons.findFirst\` round-trip that fired on every pick announcement. ## Test plan - [ ] Confirm the existing 14 unit tests in \`draft-discord.server.test.ts\` pass - [ ] In a local draft: set up a team with autodraft enabled and trigger a manual pick that causes them to immediately autodraft — confirm Discord shows two separate "on the clock" names rather than the same person twice - [ ] Confirm the final announcement (the autodraft pick) still correctly pings the actual next human drafter 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chrisp added 1 commit 2026-05-23 03:42:12 +00:00
Fix Discord double-ping when autodraft fires immediately after manual pick
All checks were successful
🚀 Deploy / 🧪 Test (pull_request) Successful in 1m33s
🚀 Deploy / ʦ TypeScript (pull_request) Successful in 1m16s
🚀 Deploy / 🔍 Lint (pull_request) Successful in 47s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
1b51cb554b
When a manual pick triggered an immediate autodraft chain, both Discord
announcements re-read currentPickNumber from the DB, which had already
advanced past the chained pick. Both messages showed the same "On the
clock" person, pinging them twice.

Fix: pass nextPickNumber (the pick immediately following each specific
pick, before any chain) as an explicit param to notifyPickMadeOnDiscord
instead of re-reading from the DB. Also removes a now-unnecessary DB
round-trip on every pick announcement.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
chrisp merged commit 4fa927e66b into main 2026-05-23 03:46:49 +00:00
Sign in to join this conversation.
No description provided.