fix(arabot): fix logic for checkActive

This commit is contained in:
smyalygames 2023-02-11 01:53:24 +00:00
parent ecf75b63e7
commit c735509f57

View File

@ -21,7 +21,7 @@ export async function addMute(userId: Snowflake, modId: Snowflake, reason: strin
} }
export async function removeMute(userId: Snowflake) { export async function removeMute(userId: Snowflake) {
const ban = await container.database.vCMute.findFirst({ const mute = await container.database.vCMute.findFirst({
where: { where: {
userId, userId,
}, },
@ -33,14 +33,14 @@ export async function removeMute(userId: Snowflake) {
}, },
}); });
if (ban === null) { if (mute === null) {
return; return;
} }
// Query to deactivate the specific sus note // Query to deactivate the specific sus note
await container.database.vCMute.update({ await container.database.vCMute.update({
where: { where: {
id: ban.id, id: mute.id,
}, },
data: { data: {
endTime: new Date(), endTime: new Date(),
@ -49,7 +49,7 @@ export async function removeMute(userId: Snowflake) {
} }
export async function checkActive(userId: Snowflake) { export async function checkActive(userId: Snowflake) {
const ban = await container.database.vCMute.findFirst({ const mute = await container.database.vCMute.findFirst({
where: { where: {
userId, userId,
}, },
@ -61,6 +61,9 @@ export async function checkActive(userId: Snowflake) {
}, },
}); });
return !(ban === null if (mute === null) {
|| ban.endTime === null); return false;
}
return mute.endTime === null;
} }