aboutsummaryrefslogtreecommitdiff
path: root/src/lib/models/shared/MemberCount.ts
blob: ea8795cf684ff9b20d6e93c66a87dfd63c29d190 (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;
}

/**
 * The member count of each guild that the bot is in that have over 100 members.
 */
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 }
		);
	}
}