From 81d69f983983ac71dbdbd5f13e2f2d8ddc35dced Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 5 Sep 2021 13:45:44 -0400 Subject: cleaning up and some imporvements to the stats command --- src/tasks/cpuUsage.ts | 15 +++++++++++++++ src/tasks/updateCache.ts | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/tasks/cpuUsage.ts (limited to 'src/tasks') diff --git a/src/tasks/cpuUsage.ts b/src/tasks/cpuUsage.ts new file mode 100644 index 0000000..a7398d7 --- /dev/null +++ b/src/tasks/cpuUsage.ts @@ -0,0 +1,15 @@ +import { BushTask } from '@lib'; +import * as osu from 'node-os-utils'; + +export default class CpuUsageTask extends BushTask { + public constructor() { + super('cpuUsage', { + delay: 60_000, // 1 minute + runOnStart: true + }); + } + public override async exec(): Promise { + const cpu = await osu.cpu.usage(client.stats.cpu === undefined ? 100 : 60_000); + client.stats.cpu = cpu; + } +} diff --git a/src/tasks/updateCache.ts b/src/tasks/updateCache.ts index 69919d8..e9d0cc6 100644 --- a/src/tasks/updateCache.ts +++ b/src/tasks/updateCache.ts @@ -4,7 +4,7 @@ import { Global } from '../lib/models/Global'; import { Guild } from '../lib/models/Guild'; import config from './../config/options'; -export class UpdateCacheTask extends BushTask { +export default class UpdateCacheTask extends BushTask { public constructor() { super('updateCache', { delay: 300_000, // 5 minutes -- cgit