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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
import { type Snowflake } from 'discord.js';
import { nanoid } from 'nanoid';
import { type Sequelize } from 'sequelize';
import { BaseModel } from '../BaseModel.js';
const { DataTypes } = (await import('sequelize')).default;
export interface HighlightModel {
pk: string;
user: Snowflake;
guild: Snowflake;
words: HighlightWord[];
blacklistedChannels: Snowflake[];
blacklistedUsers: Snowflake[];
}
export interface HighLightCreationAttributes {
pk?: string;
user: Snowflake;
guild: Snowflake;
words?: HighlightWord[];
blacklistedChannels?: Snowflake[];
blacklistedUsers?: Snowflake[];
}
export interface HighlightWord {
word: string;
regex: boolean;
}
/**
* List of words that should cause the user to be notified for if found in the specified guild.
*/
export class Highlight extends BaseModel<HighlightModel, HighLightCreationAttributes> implements HighlightModel {
/**
* The primary key of the highlight.
*/
public declare pk: string;
/**
* The user that the highlight is for.
*/
public declare user: Snowflake;
/**
* The guild to look for highlights in.
*/
public declare guild: Snowflake;
/**
* The words to look for.
*/
public declare words: HighlightWord[];
/**
* Channels that the user choose to ignore highlights in.
*/
public declare blacklistedChannels: Snowflake[];
/**
* Users that the user choose to ignore highlights from.
*/
public declare blacklistedUsers: Snowflake[];
/**
* Initializes the model.
* @param sequelize The sequelize instance.
*/
public static initModel(sequelize: Sequelize): void {
Highlight.init(
{
pk: { type: DataTypes.STRING, primaryKey: true, defaultValue: nanoid },
user: { type: DataTypes.STRING, allowNull: false },
guild: { type: DataTypes.STRING, allowNull: false },
words: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] },
blacklistedChannels: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] },
blacklistedUsers: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] }
},
{ sequelize }
);
}
}
|