diff options
Diffstat (limited to 'src/lib/models')
-rw-r--r-- | src/lib/models/Global.ts | 9 | ||||
-rw-r--r-- | src/lib/models/Guild.ts | 1 | ||||
-rw-r--r-- | src/lib/models/Level.ts | 1 | ||||
-rw-r--r-- | src/lib/models/Shared.ts | 49 | ||||
-rw-r--r-- | src/lib/models/__helpers.ts | 1 |
5 files changed, 49 insertions, 12 deletions
diff --git a/src/lib/models/Global.ts b/src/lib/models/Global.ts index 30a9d38..1deb090 100644 --- a/src/lib/models/Global.ts +++ b/src/lib/models/Global.ts @@ -2,12 +2,10 @@ import { type Snowflake } from 'discord.js'; import { type Sequelize } from 'sequelize'; import { BaseModel } from './BaseModel.js'; import { jsonArray } from './__helpers.js'; - const { DataTypes } = (await import('sequelize')).default; export interface GlobalModel { environment: 'production' | 'development' | 'beta'; - superUsers: Snowflake[]; disabledCommands: string[]; blacklistedUsers: Snowflake[]; blacklistedGuilds: Snowflake[]; @@ -16,7 +14,6 @@ export interface GlobalModel { export interface GlobalModelCreationAttributes { environment: 'production' | 'development' | 'beta'; - superUsers?: Snowflake[]; disabledCommands?: string[]; blacklistedUsers?: Snowflake[]; blacklistedGuilds?: Snowflake[]; @@ -30,11 +27,6 @@ export class Global extends BaseModel<GlobalModel, GlobalModelCreationAttributes public declare environment: 'production' | 'development' | 'beta'; /** - * Trusted users. - */ - public declare superUsers: Snowflake[]; - - /** * Globally disabled commands. */ public declare disabledCommands: string[]; @@ -62,7 +54,6 @@ export class Global extends BaseModel<GlobalModel, GlobalModelCreationAttributes Global.init( { environment: { type: DataTypes.STRING, primaryKey: true }, - superUsers: jsonArray('superUsers'), disabledCommands: jsonArray('disabledCommands'), blacklistedUsers: jsonArray('blacklistedUsers'), blacklistedGuilds: jsonArray('blacklistedGuilds'), diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts index dfee37b..80bd119 100644 --- a/src/lib/models/Guild.ts +++ b/src/lib/models/Guild.ts @@ -5,7 +5,6 @@ import { type BadWords } from '../common/AutoMod.js'; import { type BushClient } from '../extensions/discord-akairo/BushClient.js'; import { BaseModel } from './BaseModel.js'; import { jsonArray, jsonObject } from './__helpers.js'; - const { DataTypes } = (await import('sequelize')).default; export interface GuildModel { diff --git a/src/lib/models/Level.ts b/src/lib/models/Level.ts index 2ed787d..e247779 100644 --- a/src/lib/models/Level.ts +++ b/src/lib/models/Level.ts @@ -1,7 +1,6 @@ import { type Snowflake } from 'discord.js'; import { type Sequelize } from 'sequelize'; import { BaseModel } from './BaseModel.js'; - const { DataTypes } = (await import('sequelize')).default; export interface LevelModel { diff --git a/src/lib/models/Shared.ts b/src/lib/models/Shared.ts new file mode 100644 index 0000000..dd7682b --- /dev/null +++ b/src/lib/models/Shared.ts @@ -0,0 +1,49 @@ +import { type Sequelize } from 'sequelize'; +import { BaseModel } from './BaseModel.js'; +import { jsonArray } from './__helpers.js'; +const { DataTypes } = (await import('sequelize')).default; + +export interface SharedModel { + primaryKey: 0; + superUsers: string[]; + badLinks: string[]; +} + +export interface SharedModelCreationAttributes { + primaryKey?: 0; + superUsers?: string[]; + badLinks?: string[]; +} + +export class Shared extends BaseModel<SharedModel, SharedModelCreationAttributes> implements SharedModel { + /** + * The primary key of the shared model. + */ + public declare primaryKey: 0; + + /** + * Trusted users. + */ + public declare superUsers: string[]; + + //todo + /** + * Bad links. + */ + public declare badLinks: string[]; + + /** + * Initializes the model. + * @param sequelize The sequelize instance. + */ + public static initModel(sequelize: Sequelize): void { + Shared.init( + { + primaryKey: { type: DataTypes.INTEGER, primaryKey: true, validate: { min: 0, max: 0 } }, + superUsers: jsonArray('superUsers'), + badLinks: jsonArray('badLinks') + }, + { sequelize, freezeTableName: true } + ); + } +} diff --git a/src/lib/models/__helpers.ts b/src/lib/models/__helpers.ts index 049dc00..bbfe328 100644 --- a/src/lib/models/__helpers.ts +++ b/src/lib/models/__helpers.ts @@ -1,5 +1,4 @@ import { type Model } from 'sequelize'; - const { DataTypes } = (await import('sequelize')).default; export function jsonParseGet(this: Model, key: string): any { |