aboutsummaryrefslogtreecommitdiff
path: root/src/tasks/stats/guildCount.ts
blob: f52dc95ce7cfc76de7ab13451d2c7176ef74558a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { BushTask, Time } from '#lib';
import { GuildCount } from '../../../lib/models/shared/GuildCount.js';

export default class GuildCountTask extends BushTask {
	public constructor() {
		super('guildCount', {
			delay: 15 * Time.Minute,
			runOnStart: true
		});
	}

	public override async exec() {
		if (!this.client.config.isProduction) return;

		try {
			await GuildCount.create({
				environment: this.client.config.environment,
				guildCount: this.client.guilds.cache.size
			});
		} catch (err) {
			void this.client.console.error('guildCount', err);
		}
	}
}