diff --git a/functions/api/appeals/[id]/ban.ts b/functions/api/appeals/[id]/ban.ts new file mode 100644 index 0000000..e9e5f6c --- /dev/null +++ b/functions/api/appeals/[id]/ban.ts @@ -0,0 +1,33 @@ +export async function onRequestPost(context: RequestContext) { + const { current_user: currentUser } = context.data; + + await context.env.DATA.put( + `appealban_${context.data.targetId}`, + JSON.stringify({ moderator: currentUser.id }) + ); + await fetch(context.env.APPEALS_WEBHOOK, { + body: JSON.stringify({ + embeds: [ + { + title: "User Blocked", + color: 3756250, + description: `User ${context.data.targetId} was blocked from the appeal form.`, + fields: [ + { + name: "Moderator", + value: `${currentUser.username}#${currentUser.discriminator} (${currentUser.id})`, + }, + ], + }, + ], + }), + headers: { + "content-type": "application/json", + }, + method: "POST", + }); + + return new Response(null, { + status: 204, + }); +}