diff --git a/src/functions/checkLock.ts b/src/functions/checkLock.ts index 8ef6313..da8d33f 100644 --- a/src/functions/checkLock.ts +++ b/src/functions/checkLock.ts @@ -1,7 +1,9 @@ import { Client } from '..'; -export default function checkLock(client: Client): void { - setInterval(async () => { +let interval: NodeJS.Timeout; + +export default function checkLock(client: Client) { + interval = setInterval(async () => { try { const moderations = await client.db.Moderation.find(); moderations.forEach(async (moderation) => { @@ -21,4 +23,9 @@ export default function checkLock(client: Client): void { await client.util.handleError(error); } }, 10000); + return interval; +} + +export function clear() { + clearInterval(interval); } diff --git a/src/functions/checkSS.ts b/src/functions/checkSS.ts index 0367324..3a8e75e 100644 --- a/src/functions/checkSS.ts +++ b/src/functions/checkSS.ts @@ -3,8 +3,9 @@ import axios from 'axios'; import { inspect } from 'util'; import { Client } from '..'; +let interval: NodeJS.Timeout; export default function checkSS(client: Client) { - setInterval(async () => { + interval = setInterval(async () => { try { const accounts = await client.db.Account.find(); for (const { userID, homepath, hash } of accounts) { @@ -33,4 +34,9 @@ export default function checkSS(client: Client) { client.util.handleError(error); } }, 60000); + return interval; +} + +export function clear() { + clearTimeout(interval); }