Move appeal bans entirely to D1
This commit is contained in:
parent
736543c374
commit
eb550a7c36
@ -9,10 +9,12 @@ export async function onRequestPost(context: RequestContext) {
|
||||
status: 400,
|
||||
});
|
||||
|
||||
await context.env.DATA.put(
|
||||
`appealban_${context.data.targetId}`,
|
||||
JSON.stringify({ moderator: currentUser.id }),
|
||||
);
|
||||
await context.env.D1.prepare(
|
||||
"INSERT INTO appeal_bans (created_at, created_by, user) VALUES (?, ?, ?);",
|
||||
)
|
||||
.bind(Date.now(), context.data.current_user.id, context.data.targetId)
|
||||
.run();
|
||||
|
||||
await fetch(context.env.APPEALS_WEBHOOK, {
|
||||
body: JSON.stringify({
|
||||
embeds: [
|
||||
@ -23,7 +25,7 @@ export async function onRequestPost(context: RequestContext) {
|
||||
fields: [
|
||||
{
|
||||
name: "Moderator",
|
||||
value: `${currentUser.username}#${currentUser.discriminator} (${currentUser.id})`,
|
||||
value: `${currentUser.username} (${currentUser.id})`,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -52,7 +52,13 @@ export async function onRequestPost(context: RequestContext) {
|
||||
status: 403,
|
||||
});
|
||||
|
||||
if (await context.env.DATA.get(`appealban_${currentUser.id}`)) {
|
||||
if (
|
||||
(
|
||||
await context.env.D1.prepare("SELECT * FROM appeal_bans WHERE user = ?;")
|
||||
.bind(currentUser.id)
|
||||
.run()
|
||||
).results.length
|
||||
) {
|
||||
await context.env.DATA.put(`blockedappeal_${currentUser.id}`, "1", {
|
||||
metadata: { email: currentUser.email },
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user