Fix automatic unbans

This commit is contained in:
2023-10-21 00:26:33 -04:00
parent 3fb2eb20b9
commit 9212e3e454

View File

@ -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(
@ -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) {
@ -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();
@ -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, {
@ -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
});
}