Fix force-manual-pick not announcing picks on Discord
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
This commit is contained in:
parent
4a2f542fb1
commit
f7ff1f2c3e
1 changed files with 24 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue