Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make appeal action endpoints un-useless
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 962509a commit 736543c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions functions/api/appeals/[id]/accept.ts
Expand Up @@ -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",
},
Expand All @@ -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})`,
},
],
},
Expand Down
8 changes: 6 additions & 2 deletions functions/api/appeals/[id]/deny.ts
Expand Up @@ -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, {
Expand All @@ -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})`,
},
],
},
Expand Down

0 comments on commit 736543c

Please sign in to comment.