fix: Giveaway bugs
This commit is contained in:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user