Create appeal ban endpoint
This commit is contained in:
parent
75005da3b3
commit
debb8d9209
33
functions/api/appeals/[id]/ban.ts
Normal file
33
functions/api/appeals/[id]/ban.ts
Normal file
@ -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,
|
||||||
|
});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user