aboutsummaryrefslogtreecommitdiff
path: root/src/tasks/stats/guildCount.ts
blob: 262f00c6549160c5ffaf6ab1d08d638ee4ae73f1 (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);
		}
	}
}