diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-06 21:31:29 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-06 21:31:29 -0400 |
commit | bb061c938f4a967ed890f27c3ad56a63d6d6fec3 (patch) | |
tree | 10f808f2a7784235c5b19c0686f366128b6782c1 /src/tasks/updateStats.ts | |
parent | c9dbc3b7fa073889adf74a0ed47f1d5f0ad53362 (diff) | |
download | tanzanite-bb061c938f4a967ed890f27c3ad56a63d6d6fec3.tar.gz tanzanite-bb061c938f4a967ed890f27c3ad56a63d6d6fec3.tar.bz2 tanzanite-bb061c938f4a967ed890f27c3ad56a63d6d6fec3.zip |
make stats persistant, fix automod logs, pm2 bs
Diffstat (limited to 'src/tasks/updateStats.ts')
-rw-r--r-- | src/tasks/updateStats.ts | 22 |
1 files changed, 22 insertions, 0 deletions
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<void> { + 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<bigint> { + return ((await Stat.findByPk(client.config.environment)) ?? (await Stat.create({ environment: client.config.environment }))) + .commandsUsed; + } +} |