Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix automatic unbans
  • Loading branch information
regalijan committed Oct 22, 2023
1 parent 3fb2eb2 commit 9212e3e
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions functions/api/appeals/[id]/accept.ts
Expand Up @@ -10,7 +10,7 @@ export async function onRequestPost(context: RequestContext) {
context.env,
"Appeal Accepted",
context.data.body.feedback || "No additional details to display",
appeal.fcm_token,
appeal.fcm_token
);
} else {
const emailResponse = await sendEmail(
Expand All @@ -19,8 +19,8 @@ export async function onRequestPost(context: RequestContext) {
"Appeal Accepted",
"appeal_accepted",
{
note: context.data.body.feedback || "No note provided.",
},
note: context.data.body.feedback || "No note provided."
}
);

if (!emailResponse.ok) {
Expand All @@ -32,7 +32,7 @@ export async function onRequestPost(context: RequestContext) {
const { current_user: currentUser } = context.data;

await context.env.D1.prepare(
"UPDATE appeals SET approved = 1, open = 0 WHERE id = ?;",
"UPDATE appeals SET approved = 1, open = 0 WHERE id = ?;"
)
.bind(context.params.id)
.run();
Expand All @@ -43,18 +43,18 @@ export async function onRequestPost(context: RequestContext) {
appeal.open = false;

await context.env.DATA.put(`appeal_${appeal.id}`, JSON.stringify(appeal), {
expirationTtl: 94608000,
expirationTtl: 94608000
});

await fetch(
`https://discord.com/api/v10/guilds/242263977986359297/bans/${appeal.id}`,
`https://discord.com/api/v10/guilds/242263977986359297/bans/${appeal.user.id}`,
{
headers: {
authorization: `Bot ${context.env.BOT_TOKEN}`,
"x-audit-log-reason": `Appeal accepted by ${currentUser.username} (${currentUser.id})`,
"x-audit-log-reason": `Appeal accepted by ${currentUser.username} (${currentUser.id})`
},
method: "DELETE",
},
method: "DELETE"
}
);

await fetch(context.env.APPEALS_WEBHOOK, {
Expand All @@ -67,19 +67,19 @@ export async function onRequestPost(context: RequestContext) {
fields: [
{
name: "Moderator",
value: `${currentUser.username} (${currentUser.id})`,
},
],
},
],
value: `${currentUser.username} (${currentUser.id})`
}
]
}
]
}),
headers: {
"content-type": "application/json",
"content-type": "application/json"
},
method: "POST",
method: "POST"
});

return new Response(null, {
status: 204,
status: 204
});
}

0 comments on commit 9212e3e

Please sign in to comment.