aboutsummaryrefslogtreecommitdiff
path: root/lib/models/shared/GuildCount.ts
blob: 25fd6c0359ef2edbfe6fe4c3cbf8ae7af858f0eb (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Environment } from '#config';
import { DataTypes, Model, type Sequelize } from 'sequelize';

export interface GuildCountModel {
	timestamp: Date;
	environment: Environment;
	guildCount: number;
}

export interface GuildCountCreationAttributes {
	timestamp?: Date;
	environment: Environment;
	guildCount: number;
}

/**
 * The number of guilds that the bot is in for each environment.
 */
export class GuildCount extends Model<GuildCountModel, GuildCountCreationAttributes> implements GuildCountModel {
	public declare timestamp: Date;
	public declare environment: Environment;
	public declare guildCount: number;

	/**
	 * Initializes the model.
	 * @param sequelize The sequelize instance.
	 */
	public static initModel(sequelize: Sequelize): void {
		GuildCount.init(
			{
				timestamp: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
				environment: { type: DataTypes.STRING, allowNull: false },
				guildCount: { type: DataTypes.BIGINT, allowNull: false }
			},
			{ sequelize, timestamps: false }
		);
	}
}