Skip to content
Permalink
05a0d192c3
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Latest commit 026d1ca Oct 19, 2023 History
1 contributor

Users who have contributed to this file

41 lines (38 sloc) 1.05 KB
export async function onRequestPost(context: RequestContext) {
const { current_user: currentUser } = context.data;
if (context.data.targetId.search(/^\d{16,19}$/) === -1)
return new Response('{"error":"Invalid target id"}', {
headers: {
"content-type": "application/json",
},
status: 400,
});
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,
});
}