aboutsummaryrefslogtreecommitdiff
path: root/src/tasks/feature/updateStats.ts
blob: ded7aa171c7d15151d6279839b22f45cdc9e33a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { BotTask, Stat, Time } from '#lib';

export default class UpdateStatsTask extends BotTask {
	public constructor() {
		super('updateStats', {
			delay: 10 * Time.Minute,
			runOnStart: true
		});
	}

	public async exec() {
		const row =
			(await Stat.findByPk(this.client.config.environment)) ??
			(await Stat.create({ environment: this.client.config.environment }));
		row.commandsUsed = this.client.stats.commandsUsed;
		row.slashCommandsUsed = this.client.stats.slashCommandsUsed;
		await row.save();
	}
}