aboutsummaryrefslogtreecommitdiff
path: root/src/tasks
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-06 21:31:29 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-09-06 21:31:29 -0400
commitbb061c938f4a967ed890f27c3ad56a63d6d6fec3 (patch)
tree10f808f2a7784235c5b19c0686f366128b6782c1 /src/tasks
parentc9dbc3b7fa073889adf74a0ed47f1d5f0ad53362 (diff)
downloadtanzanite-bb061c938f4a967ed890f27c3ad56a63d6d6fec3.tar.gz
tanzanite-bb061c938f4a967ed890f27c3ad56a63d6d6fec3.tar.bz2
tanzanite-bb061c938f4a967ed890f27c3ad56a63d6d6fec3.zip
make stats persistant, fix automod logs, pm2 bs
Diffstat (limited to 'src/tasks')
-rw-r--r--src/tasks/updateStats.ts22
-rw-r--r--src/tasks/updateSuperUsers.ts2
2 files changed, 23 insertions, 1 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;
+ }
+}
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
});
}