From f7ff1f2c3e10c0669719af2534c1ee25d832ee56 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 29 May 2026 02:29:06 +0000 Subject: [PATCH] Fix force-manual-pick not announcing picks on Discord MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a commissioner used force-manual-pick for a team with while_on autodraft, Discord was never notified. The pick was committed to the DB without calling notifyPickMadeOnDiscord, and when the timer subsequently fired for that team it hit the "Pick already made" early-return path — also without calling Discord — leaving the pick silently unannounced. Mirrors the same enqueuePickNotification pattern already used by make-pick.ts and executeAutoPick. https://claude.ai/code/session_01PE3Db1JMW2a1eg91UMvwch --- app/routes/api/draft.force-manual-pick.ts | 25 ++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/app/routes/api/draft.force-manual-pick.ts b/app/routes/api/draft.force-manual-pick.ts index 6350d8d..c0d672b 100644 --- a/app/routes/api/draft.force-manual-pick.ts +++ b/app/routes/api/draft.force-manual-pick.ts @@ -12,6 +12,8 @@ import { logCommissionerAction } from "~/models/audit-log"; import { getSocketIO, scheduleDraftRoomClosure } from "../../../server/socket"; import { logger } from "~/lib/logger"; import { runBracktHarvilleForFantasySeason } from "~/services/brackt.server"; +import { enqueuePickNotification } from "~/services/discord"; +import { notifyPickMadeOnDiscord } from "~/services/draft-discord.server"; import type { ActionFunctionArgs } from "react-router"; export async function action(args: ActionFunctionArgs) { @@ -113,7 +115,7 @@ export async function action(args: ActionFunctionArgs) { }); const totalTeams = draftSlots.length; - const { round: currentRound, pickInRound } = calculatePickInfo(pickNumber, totalTeams); + const { round: currentRound, pickInRound, rawPickInRound } = calculatePickInfo(pickNumber, totalTeams); // Validate that the submitted teamId is actually the team whose turn it is at pickNumber const expectedDraftSlot = draftSlots.find((slot) => slot.draftOrder === pickInRound); @@ -264,6 +266,27 @@ export async function action(args: ActionFunctionArgs) { const pickedTeam = draftSlots.find((slot) => slot.team.id === teamId)?.team; + // Announce on Discord before triggering the chain so pick-number order is preserved + if (pickedTeam) { + enqueuePickNotification(season.leagueId, () => + notifyPickMadeOnDiscord({ + seasonId, + leagueId: season.leagueId, + pickedTeamName: pickedTeam.name, + participantName: participant.name, + sportName: participant.sportsSeason.sport.name, + pickNumber, + nextPickNumber, + round: currentRound, + rawPickInRound, + isDraftComplete, + totalTeams, + draftSlots: draftSlots.map((s) => ({ teamId: s.teamId, draftOrder: s.draftOrder })), + db, + }).catch((err) => logger.error("Discord pick announcement failed:", err)) + ); + } + await logCommissionerAction({ seasonId, leagueId: season.leagueId,