From 2e036d58800c9f466064eea47454116d0ad860c4 Mon Sep 17 00:00:00 2001 From: 7cc5c4f330d47060 Date: Wed, 30 Oct 2024 14:11:49 -0400 Subject: [PATCH] Selfcare fixes --- plugins/selfcare.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/selfcare.js b/plugins/selfcare.js index 5b35363..52a94a5 100755 --- a/plugins/selfcare.js +++ b/plugins/selfcare.js @@ -16,17 +16,19 @@ module.exports = { load: (b) => { b.sc_tasks = {} b.selfcareRun = 0 - b.interval.sc = setInterval(() => { - if (Date.now() - b.selfcareRun <= 600) { - return - } - for (const i in b.sc_tasks) { - if (b.sc_tasks[i].failed) { - b.sc_tasks[i].failTask() + b._client.on('login', () => { + b.interval.sc = setInterval(() => { + if (Date.now() - b.selfcareRun <= 600) { + return } - } - b.selfcareRun = Date.now() - }, 40) + for (const i in b.sc_tasks) { + if (b.sc_tasks[i].failed) { + b.sc_tasks[i].failTask() + b.selfcareRun = Date.now() + } + } + }, 40) + }) b.add_sc_task = (name, failTask, startFailed) => { b.sc_tasks[name] = new SCTask(failTask, startFailed) }