fix: Giveaway bugs

This commit is contained in:
smueller
2026-07-24 10:33:56 +02:00
parent bd1b55fff7
commit f2406fb6d7
7 changed files with 74 additions and 25 deletions

View File

@@ -115,16 +115,24 @@ export async function endGiveawayDashboard(guildId: string, giveawayId: string):
const existingJob = await getGiveawayQueue().getJob(`giveaway-end-${giveawayId}`);
await existingJob?.remove();
await addJobAndAwait(
const { confirmed } = await addJobAndAwait(
getGiveawayQueue(),
getGiveawayQueueEvents(),
'giveawayEnd',
{ giveawayId },
{ jobId: `giveaway-end-${giveawayId}`, removeOnComplete: true, removeOnFail: 50, delay: 0 }
{ jobId: `giveaway-end-${giveawayId}`, removeOnComplete: true, removeOnFail: 50, delay: 0 },
30_000
);
const updated = await prisma.giveaway.findUnique({ where: { id: giveawayId } });
return updated ? toDashboard(updated) : null;
if (!updated?.endedAt) {
throw new Error(
confirmed
? 'Giveaway end job finished without marking the giveaway as ended'
: 'Giveaway end timed out the bot may still be processing; refresh and retry'
);
}
return toDashboard(updated);
}
export async function deleteGiveawayDashboard(guildId: string, giveawayId: string): Promise<boolean> {