fix: fix potential issues with trivia command

This commit is contained in:
syntaxbullet
2026-01-11 15:00:10 +01:00
parent 35bd1f58dd
commit 7d68652ea5
3 changed files with 14 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
import { users, userTimers, transactions } from "@db/schema";
import { eq, and } from "drizzle-orm";
import { eq, and, sql } from "drizzle-orm";
import { config } from "@shared/lib/config";
import { withTransaction } from "@/lib/db";
import type { Transaction } from "@shared/lib/types";
@@ -171,7 +171,7 @@ class TriviaService {
// Deduct entry fee (SINK MECHANISM)
await tx.update(users)
.set({
balance: (user.balance ?? 0n) - entryFee,
balance: sql`${users.balance} - ${entryFee}`,
})
.where(eq(users.id, BigInt(userId)));