feat(arabot): add unrestrict legacy restrictions to database

This commit is contained in:
smyalygames 2023-02-14 01:07:32 +00:00
parent 3632aaa276
commit 9e833b87fd

View File

@ -1,7 +1,12 @@
import { container } from '@sapphire/framework'; import { container } from '@sapphire/framework';
import type { Snowflake } from 'discord.js'; 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 // Add the user to the database
await container.database.restrict.create({ await container.database.restrict.create({
data: { data: {
@ -16,6 +21,7 @@ export async function restrict(userId: Snowflake, modId: Snowflake, reason: stri
}, },
}, },
reason, reason,
section,
}, },
}); });
} }
@ -37,7 +43,6 @@ export async function unRestrict(userId: Snowflake, modId: Snowflake) {
return; return;
} }
// Query to deactivate the specific sus note
await container.database.restrict.update({ await container.database.restrict.update({
where: { where: {
id: restriction.id, id: restriction.id,
@ -72,3 +77,28 @@ export async function checkActive(userId: Snowflake) {
return restriction.endTime === null; 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,
},
});
}