blob: 74a8114b10380ab96de605dde5d5b1587a70ef4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import { Stat } from '@lib';
import { BushTask } from '../lib/extensions/discord-akairo/BushTask';
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;
}
}
|