From 48631e32be1c0d1ae0f1f57f2c0d7a2a28398b26 Mon Sep 17 00:00:00 2001 From: Regalijan Date: Sat, 11 Apr 2026 04:29:25 -0400 Subject: [PATCH] Finish rest of game appeal stuff --- functions/api/game-appeals/precheck.ts | 43 ++++++++++++-------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/functions/api/game-appeals/precheck.ts b/functions/api/game-appeals/precheck.ts index 560d136..5526821 100644 --- a/functions/api/game-appeals/precheck.ts +++ b/functions/api/game-appeals/precheck.ts @@ -10,11 +10,14 @@ export default async function ( types?: string[]; }> { if ( - await context.env.D1.prepare( - "SELECT * FROM game_appeals WHERE roblox_id = ?;", - ) - .bind(user) - .first() + await context.data.prisma.gameAppeal.findFirst({ + select: { + id: true, + }, + where: { + roblox_id: user, + }, + }) ) return { can_appeal: false, @@ -47,22 +50,20 @@ export default async function ( ).toLocaleString()} to submit another appeal`, }; - const userLogs = await context.env.D1.prepare( - "SELECT action, executed_at FROM game_mod_logs WHERE target = ? ORDER BY executed_at DESC;", - ) - .bind(user) - .all(); - - if (userLogs.error) - return { - error: "Could not determine your eligibility", - }; + const userLogs = await context.data.prisma.gameModLog.findMany({ + select: { + action: true, + executed_at: true, + }, + where: { + target: user, + }, + }); // Legacy bans - if (!userLogs.results.length) - return { can_appeal: true, reason: "", types: ["ban"] }; + if (!userLogs.length) return { can_appeal: true, reason: "", types: ["ban"] }; - const allowedTime = (userLogs.results[0].executed_at as number) + 2592000000; + const allowedTime = new Date(userLogs[0].executed_at).getTime() + 2592000000; if (Date.now() < allowedTime) return { @@ -72,11 +73,7 @@ export default async function ( ).toLocaleString()} to submit an appeal`, }; - if ( - userLogs.results.find((r: Record) => - r.action.startsWith("accept appeal"), - ) - ) + if (userLogs.find((r) => r.action.startsWith("accept appeal"))) return { can_appeal: false, reason: "We do not accept appeals from repeat offenders",