Make appeal action endpoints un-useless

This commit is contained in:
regalijan 2023-10-19 16:50:40 -04:00
parent 962509aff2
commit 736543c374
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520
2 changed files with 13 additions and 5 deletions

View File

@ -30,12 +30,16 @@ export async function onRequestPost(context: RequestContext) {
const { current_user: currentUser } = context.data;
await context.env.D1.prepare("UPDATE appeals SET open = 0 WHERE id = ?;")
.bind(context.params.id)
.run();
await fetch(
`https://discord.com/api/v10/guilds/242263977986359297/bans/${appeal.id}`,
{
headers: {
authorization: `Bot ${context.env.BOT_TOKEN}`,
"x-audit-log-reason": `Appeal accepted by ${currentUser.username}#${currentUser.discriminator} (${currentUser.id})`,
"x-audit-log-reason": `Appeal accepted by ${currentUser.username} (${currentUser.id})`,
},
method: "DELETE",
},
@ -47,11 +51,11 @@ export async function onRequestPost(context: RequestContext) {
{
title: "Appeal Accepted",
color: 0x00ff00,
description: `Appeal from user ${appeal.username}#${appeal.discriminator} (${appeal.id}) was accepted.`,
description: `Appeal from user ${appeal.username} (${appeal.id}) was accepted.`,
fields: [
{
name: "Moderator",
value: `${currentUser.username}#${currentUser.discriminator} (${currentUser.id})`,
value: `${currentUser.username} (${currentUser.id})`,
},
],
},

View File

@ -28,6 +28,10 @@ export async function onRequestPost(context: RequestContext) {
});
}
await context.env.D1.prepare("UPDATE appeals SET open = 0 WHERE id = ?;")
.bind(context.params.id)
.run();
const { current_user: currentUser } = context.data;
await fetch(context.env.APPEALS_WEBHOOK, {
@ -36,11 +40,11 @@ export async function onRequestPost(context: RequestContext) {
{
title: "Appeal Denied",
color: 0xff0000,
description: `Appeal from user ${appeal.username}#${appeal.discriminator} (${appeal.id}) was denied.`,
description: `Appeal from user ${appeal.username} (${appeal.id}) was denied.`,
fields: [
{
name: "Moderator",
value: `${currentUser.username}#${currentUser.discriminator} (${currentUser.id})`,
value: `${currentUser.username} (${currentUser.id})`,
},
],
},