aboutsummaryrefslogtreecommitdiff
path: root/src/lib/models/shared/MemberCount.ts
blob: 409d1ac2b9420a42d9a63880c8f51f028f68f8ba (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 { type Sequelize } from 'sequelize';
const { DataTypes, Model } = (await import('sequelize')).default;

export interface MemberCountModel {
	timestamp: Date;
	guildId: string;
	memberCount: number;
}

export interface MemberCountCreationAttributes {
	timestamp?: Date;
	guildId: string;
	memberCount: number;
}

/**
 * Data specific to a certain instance of the bot.
 */
export class MemberCount extends Model<MemberCountModel, MemberCountCreationAttributes> implements MemberCountModel {
	public declare timestamp: Date;
	public declare guildId: string;
	public declare memberCount: number;

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