From bb061c938f4a967ed890f27c3ad56a63d6d6fec3 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Mon, 6 Sep 2021 21:31:29 -0400 Subject: make stats persistant, fix automod logs, pm2 bs --- src/tasks/updateStats.ts | 22 ++++++++++++++++++++++ src/tasks/updateSuperUsers.ts | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/tasks/updateStats.ts (limited to 'src/tasks') diff --git a/src/tasks/updateStats.ts b/src/tasks/updateStats.ts new file mode 100644 index 0000000..7b0690f --- /dev/null +++ b/src/tasks/updateStats.ts @@ -0,0 +1,22 @@ +import { BushTask } from '../lib/extensions/discord-akairo/BushTask'; +import { Stat } from '../lib/models/Stat'; + +export default class UpdateStatsTask extends BushTask { + public constructor() { + super('updateStats', { + delay: 600_000, // 10 minutes + runOnStart: true + }); + } + public override async exec(): Promise { + const row = + (await Stat.findByPk(client.config.environment)) ?? (await Stat.create({ environment: client.config.environment })); + row.commandsUsed = client.stats.commandsUsed; + await row.save(); + } + + public static async init(): Promise { + return ((await Stat.findByPk(client.config.environment)) ?? (await Stat.create({ environment: client.config.environment }))) + .commandsUsed; + } +} diff --git a/src/tasks/updateSuperUsers.ts b/src/tasks/updateSuperUsers.ts index 5b1555f..e0e51f5 100644 --- a/src/tasks/updateSuperUsers.ts +++ b/src/tasks/updateSuperUsers.ts @@ -4,7 +4,7 @@ import { Global } from '../lib/models/Global'; export default class UpdateSuperUsersTask extends BushTask { public constructor() { super('updateSuperUsers', { - delay: 300_000, // 5 minutes + delay: 10_000, runOnStart: true }); } -- cgit