Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Create appeal ban endpoint
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 75005da commit debb8d9
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions 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,
});
}

0 comments on commit debb8d9

Please sign in to comment.