Allow clearing of function

merge-requests/4/head
Bsian 2020-01-03 15:55:23 +00:00
parent bdfbb94ce7
commit 7a38e68048
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
2 changed files with 16 additions and 3 deletions

View File

@ -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);
}

View File

@ -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);
}