Timed bans feature

This commit is contained in:
Kalle
2024-04-11 20:59:05 +03:00
parent 6d68eecaae
commit 7f25bbcd78
22 changed files with 459 additions and 189 deletions

View File

@@ -114,3 +114,30 @@ export function forcePatron(args: {
.where("User.id", "=", args.id)
.execute();
}
export function banUser({
userId,
banned,
bannedReason,
}: {
userId: number;
banned: 1 | Date;
bannedReason: string | null;
}) {
return db
.updateTable("User")
.set({
banned: banned === 1 ? banned : dateToDatabaseTimestamp(banned),
bannedReason,
})
.where("User.id", "=", userId)
.execute();
}
export function unbanUser(userId: number) {
return db
.updateTable("User")
.set({ banned: 0 })
.where("User.id", "=", userId)
.execute();
}