From 9e833b87fde0df1108adcebde24ee95a14b91ab2 Mon Sep 17 00:00:00 2001 From: smyalygames Date: Tue, 14 Feb 2023 01:07:32 +0000 Subject: [PATCH] feat(arabot): add unrestrict legacy restrictions to database --- src/utils/database/restriction.ts | 34 +++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/utils/database/restriction.ts b/src/utils/database/restriction.ts index a86deb0..e7c37ff 100644 --- a/src/utils/database/restriction.ts +++ b/src/utils/database/restriction.ts @@ -1,7 +1,12 @@ import { container } from '@sapphire/framework'; import type { Snowflake } from 'discord.js'; -export async function restrict(userId: Snowflake, modId: Snowflake, reason: string) { +export async function restrict( + userId: Snowflake, + modId: Snowflake, + reason: string, + section: number, +) { // Add the user to the database await container.database.restrict.create({ data: { @@ -16,6 +21,7 @@ export async function restrict(userId: Snowflake, modId: Snowflake, reason: stri }, }, reason, + section, }, }); } @@ -37,7 +43,6 @@ export async function unRestrict(userId: Snowflake, modId: Snowflake) { return; } - // Query to deactivate the specific sus note await container.database.restrict.update({ where: { id: restriction.id, @@ -72,3 +77,28 @@ export async function checkActive(userId: Snowflake) { return restriction.endTime === null; } + +// This is only for restrictions created with the old bot +export async function unRestrictLegacy(userId: Snowflake, modId: Snowflake, section: number) { + await container.database.restrict.create({ + data: { + user: { + connect: { + id: userId, + }, + }, + mod: { + connect: { + id: modId, + }, + }, + endMod: { + connect: { + id: modId, + }, + }, + reason: 'This user was restricted with the old bot. Restrict reason, time and mod unknown, check old bot logs.', + section, + }, + }); +}