aboutsummaryrefslogtreecommitdiff
path: root/src/lib/models
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/models')
-rw-r--r--src/lib/models/ActivePunishment.ts (renamed from src/lib/models/PunishmentRole.ts)53
-rw-r--r--src/lib/models/Ban.ts80
-rw-r--r--src/lib/models/ModLog.ts5
-rw-r--r--src/lib/models/Mute.ts80
4 files changed, 39 insertions, 179 deletions
diff --git a/src/lib/models/PunishmentRole.ts b/src/lib/models/ActivePunishment.ts
index 0b54f31..9fcafbe 100644
--- a/src/lib/models/PunishmentRole.ts
+++ b/src/lib/models/ActivePunishment.ts
@@ -3,54 +3,67 @@ import { DataTypes, Sequelize } from 'sequelize';
import { v4 as uuidv4 } from 'uuid';
import { BaseModel } from './BaseModel';
-export interface PunishmentRoleModel {
+export enum ActivePunishmentType {
+ BAN = 'BAN',
+ MUTE = 'MUTE',
+ ROLE = 'ROLE',
+ BLOCK = 'BLOCK'
+}
+
+export interface ActivePunishmentModel {
id: string;
+ type: ActivePunishmentType;
user: Snowflake;
- role: Snowflake;
guild: Snowflake;
+ extraInfo: Snowflake;
expires: Date;
modlog: string;
}
-export interface PunishmentRoleModelCreationAttributes {
+export interface ActivePunishmentModelCreationAttributes {
id?: string;
+ type: ActivePunishmentType;
user: Snowflake;
- role?: Snowflake;
guild: Snowflake;
+ extraInfo?: Snowflake;
expires?: Date;
modlog: string;
}
-export class PunishmentRole
- extends BaseModel<PunishmentRoleModel, PunishmentRoleModelCreationAttributes>
- implements PunishmentRoleModel
+export class ActivePunishment
+ extends BaseModel<ActivePunishmentModel, ActivePunishmentModelCreationAttributes>
+ implements ActivePunishmentModel
{
/**
- * The ID of this punishment role (no real use just for a primary key)
+ * The ID of this punishment (no real use just for a primary key)
*/
id: string;
/**
- * The user who received a role
+ * The type of punishment.
*/
- user: Snowflake;
+ type: ActivePunishmentType;
/**
- * The role added to the user.
+ * The user who is punished.
*/
- role: Snowflake;
+ user: Snowflake;
/**
- * The guild they received a role in
+ * The guild they are punished in.
*/
guild: Snowflake;
/**
- * The date at which this role expires and should be removed (optional)
+ * Additional info about the punishment if applicable. The channel id for channel blocks and role for punishment roles.
+ */
+ extraInfo: Snowflake;
+ /**
+ * The date when this punishment expires (optional).
*/
expires: Date | null;
/**
- * The ref to the modlog entry
+ * The reference to the modlog entry.
*/
modlog: string;
static initModel(sequelize: Sequelize): void {
- PunishmentRole.init(
+ ActivePunishment.init(
{
id: {
type: DataTypes.STRING,
@@ -58,11 +71,11 @@ export class PunishmentRole
allowNull: false,
defaultValue: uuidv4
},
- user: {
+ type: {
type: DataTypes.STRING,
allowNull: false
},
- role: {
+ user: {
type: DataTypes.STRING,
allowNull: false
},
@@ -74,6 +87,10 @@ export class PunishmentRole
key: 'id'
}
},
+ extraInfo: {
+ type: DataTypes.DATE,
+ allowNull: true
+ },
expires: {
type: DataTypes.DATE,
allowNull: true
diff --git a/src/lib/models/Ban.ts b/src/lib/models/Ban.ts
deleted file mode 100644
index 1bdda6f..0000000
--- a/src/lib/models/Ban.ts
+++ /dev/null
@@ -1,80 +0,0 @@
-import { Snowflake } from 'discord.js';
-import { DataTypes, Sequelize } from 'sequelize';
-import { v4 as uuidv4 } from 'uuid';
-import { BaseModel } from './BaseModel';
-
-export interface BanModel {
- id: string;
- user: Snowflake;
- guild: Snowflake;
- expires: Date;
- modlog: string;
-}
-export interface BanModelCreationAttributes {
- id?: string;
- user: Snowflake;
- guild: Snowflake;
- expires?: Date;
- modlog: string;
-}
-
-export class Ban extends BaseModel<BanModel, BanModelCreationAttributes> implements BanModel {
- /**
- * The ID of this ban (no real use just for a primary key)
- */
- id: string;
- /**
- * The user who is banned
- */
- user: Snowflake;
- /**
- * The guild they are banned from
- */
- guild: Snowflake;
- /**
- * The date at which this ban expires and should be unbanned (optional)
- */
- expires: Date | null;
- /**
- * The ref to the modlog entry
- */
- modlog: string;
-
- static initModel(sequelize: Sequelize): void {
- Ban.init(
- {
- id: {
- type: DataTypes.STRING,
- primaryKey: true,
- allowNull: false,
- defaultValue: uuidv4
- },
- user: {
- type: DataTypes.STRING,
- allowNull: false
- },
- guild: {
- type: DataTypes.STRING,
- allowNull: false,
- references: {
- model: 'Guilds',
- key: 'id'
- }
- },
- expires: {
- type: DataTypes.DATE,
- allowNull: true
- },
- modlog: {
- type: DataTypes.STRING,
- allowNull: false,
- references: {
- model: 'ModLogs',
- key: 'id'
- }
- }
- },
- { sequelize: sequelize }
- );
- }
-}
diff --git a/src/lib/models/ModLog.ts b/src/lib/models/ModLog.ts
index 40dc86d..3375751 100644
--- a/src/lib/models/ModLog.ts
+++ b/src/lib/models/ModLog.ts
@@ -14,7 +14,10 @@ export enum ModLogType {
WARN = 'WARN',
PERM_PUNISHMENT_ROLE = 'PERM_PUNISHMENT_ROLE',
TEMP_PUNISHMENT_ROLE = 'TEMP_PUNISHMENT_ROLE',
- REMOVE_PUNISHMENT_ROLE = 'REMOVE_PUNISHMENT_ROLE'
+ REMOVE_PUNISHMENT_ROLE = 'REMOVE_PUNISHMENT_ROLE',
+ PERM_CHANNEL_BLOCK = 'PERM_CHANNEL_BLOCK',
+ TEMP_CHANNEL_BLOCK = 'TEMP_CHANNEL_BLOCK',
+ CHANNEL_UNBLOCK = 'CHANNEL_UNBLOCK'
}
export interface ModLogModel {
diff --git a/src/lib/models/Mute.ts b/src/lib/models/Mute.ts
deleted file mode 100644
index 4208d02..0000000
--- a/src/lib/models/Mute.ts
+++ /dev/null
@@ -1,80 +0,0 @@
-import { Snowflake } from 'discord.js';
-import { DataTypes, Sequelize } from 'sequelize';
-import { v4 as uuidv4 } from 'uuid';
-import { BaseModel } from './BaseModel';
-
-export interface MuteModel {
- id: string;
- user: Snowflake;
- guild: Snowflake;
- expires: Date;
- modlog: string;
-}
-export interface MuteModelCreationAttributes {
- id?: string;
- user: Snowflake;
- guild: Snowflake;
- expires?: Date;
- modlog: string;
-}
-
-export class Mute extends BaseModel<MuteModel, MuteModelCreationAttributes> implements MuteModel {
- /**
- * The ID of this mute (no real use just for a primary key)
- */
- id: string;
- /**
- * The user who is muted
- */
- user: Snowflake;
- /**
- * The guild they are muted in
- */
- guild: Snowflake;
- /**
- * The date at which this Mute expires and should be unmuted (optional)
- */
- expires: Date | null;
- /**
- * The ref to the modlog entry
- */
- modlog: string;
-
- static initModel(sequelize: Sequelize): void {
- Mute.init(
- {
- id: {
- type: DataTypes.STRING,
- primaryKey: true,
- allowNull: false,
- defaultValue: uuidv4
- },
- user: {
- type: DataTypes.STRING,
- allowNull: false
- },
- guild: {
- type: DataTypes.STRING,
- allowNull: false,
- references: {
- model: 'Guilds',
- key: 'id'
- }
- },
- expires: {
- type: DataTypes.DATE,
- allowNull: true
- },
- modlog: {
- type: DataTypes.STRING,
- allowNull: false,
- references: {
- model: 'ModLogs',
- key: 'id'
- }
- }
- },
- { sequelize: sequelize }
- );
- }
-}