From 9212e3e4546866e7b878bfebc6eea449fcb5b252 Mon Sep 17 00:00:00 2001 From: Regalijan Date: Sat, 21 Oct 2023 00:26:33 -0400 Subject: [PATCH] Fix automatic unbans --- functions/api/appeals/[id]/accept.ts | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/functions/api/appeals/[id]/accept.ts b/functions/api/appeals/[id]/accept.ts index 739ac2c..e920a07 100644 --- a/functions/api/appeals/[id]/accept.ts +++ b/functions/api/appeals/[id]/accept.ts @@ -10,7 +10,7 @@ export async function onRequestPost(context: RequestContext) { context.env, "Appeal Accepted", context.data.body.feedback || "No additional details to display", - appeal.fcm_token, + appeal.fcm_token ); } else { const emailResponse = await sendEmail( @@ -19,8 +19,8 @@ export async function onRequestPost(context: RequestContext) { "Appeal Accepted", "appeal_accepted", { - note: context.data.body.feedback || "No note provided.", - }, + note: context.data.body.feedback || "No note provided." + } ); if (!emailResponse.ok) { @@ -32,7 +32,7 @@ export async function onRequestPost(context: RequestContext) { const { current_user: currentUser } = context.data; await context.env.D1.prepare( - "UPDATE appeals SET approved = 1, open = 0 WHERE id = ?;", + "UPDATE appeals SET approved = 1, open = 0 WHERE id = ?;" ) .bind(context.params.id) .run(); @@ -43,18 +43,18 @@ export async function onRequestPost(context: RequestContext) { appeal.open = false; await context.env.DATA.put(`appeal_${appeal.id}`, JSON.stringify(appeal), { - expirationTtl: 94608000, + expirationTtl: 94608000 }); await fetch( - `https://discord.com/api/v10/guilds/242263977986359297/bans/${appeal.id}`, + `https://discord.com/api/v10/guilds/242263977986359297/bans/${appeal.user.id}`, { headers: { authorization: `Bot ${context.env.BOT_TOKEN}`, - "x-audit-log-reason": `Appeal accepted by ${currentUser.username} (${currentUser.id})`, + "x-audit-log-reason": `Appeal accepted by ${currentUser.username} (${currentUser.id})` }, - method: "DELETE", - }, + method: "DELETE" + } ); await fetch(context.env.APPEALS_WEBHOOK, { @@ -67,19 +67,19 @@ export async function onRequestPost(context: RequestContext) { fields: [ { name: "Moderator", - value: `${currentUser.username} (${currentUser.id})`, - }, - ], - }, - ], + value: `${currentUser.username} (${currentUser.id})` + } + ] + } + ] }), headers: { - "content-type": "application/json", + "content-type": "application/json" }, - method: "POST", + method: "POST" }); return new Response(null, { - status: 204, + status: 204 }); }