aboutsummaryrefslogtreecommitdiff
path: root/src/lib/models/Shared.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-08 20:08:16 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-08 20:08:16 -0500
commite0531157a745ac6178d55cc159b5932fa36ff20f (patch)
treea8de340d0c48269619e9bfde536932eb08556593 /src/lib/models/Shared.ts
parent0e160ae77477f0986a02746e84158329299f438f (diff)
downloadtanzanite-e0531157a745ac6178d55cc159b5932fa36ff20f.tar.gz
tanzanite-e0531157a745ac6178d55cc159b5932fa36ff20f.tar.bz2
tanzanite-e0531157a745ac6178d55cc159b5932fa36ff20f.zip
database migrations - use jsonb over text + JSON.parse, refactor bad word & automod - store word in shared db
closes: #53
Diffstat (limited to 'src/lib/models/Shared.ts')
-rw-r--r--src/lib/models/Shared.ts42
1 files changed, 33 insertions, 9 deletions
diff --git a/src/lib/models/Shared.ts b/src/lib/models/Shared.ts
index dd7682b..a240ef9 100644
--- a/src/lib/models/Shared.ts
+++ b/src/lib/models/Shared.ts
@@ -1,18 +1,25 @@
-import { type Sequelize } from 'sequelize';
+import { Snowflake } from 'discord.js';
+import type { Sequelize } from 'sequelize';
+import type { BadWords } from '../common/AutoMod.js';
import { BaseModel } from './BaseModel.js';
-import { jsonArray } from './__helpers.js';
const { DataTypes } = (await import('sequelize')).default;
export interface SharedModel {
primaryKey: 0;
- superUsers: string[];
+ superUsers: Snowflake[];
+ privilegedUsers: Snowflake[];
+ badLinksSecret: string[];
badLinks: string[];
+ badWords: BadWords;
}
export interface SharedModelCreationAttributes {
primaryKey?: 0;
- superUsers?: string[];
+ superUsers?: Snowflake[];
+ privilegedUsers?: Snowflake[];
+ badLinksSecret?: string[];
badLinks?: string[];
+ badWords?: BadWords;
}
export class Shared extends BaseModel<SharedModel, SharedModelCreationAttributes> implements SharedModel {
@@ -24,15 +31,29 @@ export class Shared extends BaseModel<SharedModel, SharedModelCreationAttributes
/**
* Trusted users.
*/
- public declare superUsers: string[];
+ public declare superUsers: Snowflake[];
- //todo
/**
- * Bad links.
+ * Users that have all permissions that devs have except eval.
+ */
+ public declare privilegedUsers: Snowflake[];
+
+ /**
+ * Non-public bad links.
+ */
+ public declare badLinksSecret: string[];
+
+ /**
+ * Public Bad links.
*/
public declare badLinks: string[];
/**
+ * Bad words.
+ */
+ public declare badWords: BadWords;
+
+ /**
* Initializes the model.
* @param sequelize The sequelize instance.
*/
@@ -40,8 +61,11 @@ export class Shared extends BaseModel<SharedModel, SharedModelCreationAttributes
Shared.init(
{
primaryKey: { type: DataTypes.INTEGER, primaryKey: true, validate: { min: 0, max: 0 } },
- superUsers: jsonArray('superUsers'),
- badLinks: jsonArray('badLinks')
+ superUsers: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] },
+ privilegedUsers: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] },
+ badLinksSecret: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] },
+ badLinks: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] },
+ badWords: { type: DataTypes.JSONB, allowNull: false, defaultValue: {} }
},
{ sequelize, freezeTableName: true }
);