diff options
Diffstat (limited to 'src/lib/models/shared')
-rw-r--r-- | src/lib/models/shared/Global.ts | 67 | ||||
-rw-r--r-- | src/lib/models/shared/GuildCount.ts | 39 | ||||
-rw-r--r-- | src/lib/models/shared/MemberCount.ts | 38 | ||||
-rw-r--r-- | src/lib/models/shared/Shared.ts | 84 | ||||
-rw-r--r-- | src/lib/models/shared/Stat.ts | 72 |
5 files changed, 0 insertions, 300 deletions
diff --git a/src/lib/models/shared/Global.ts b/src/lib/models/shared/Global.ts deleted file mode 100644 index b1aa0cc..0000000 --- a/src/lib/models/shared/Global.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { type Snowflake } from 'discord.js'; -import { type Sequelize } from 'sequelize'; -import { BaseModel } from '../BaseModel.js'; -const { DataTypes } = (await import('sequelize')).default; - -export interface GlobalModel { - environment: 'production' | 'development' | 'beta'; - disabledCommands: string[]; - blacklistedUsers: Snowflake[]; - blacklistedGuilds: Snowflake[]; - blacklistedChannels: Snowflake[]; -} - -export interface GlobalModelCreationAttributes { - environment: 'production' | 'development' | 'beta'; - disabledCommands?: string[]; - blacklistedUsers?: Snowflake[]; - blacklistedGuilds?: Snowflake[]; - blacklistedChannels?: Snowflake[]; -} - -/** - * Data specific to a certain instance of the bot. - */ -export class Global extends BaseModel<GlobalModel, GlobalModelCreationAttributes> implements GlobalModel { - /** - * The bot's environment. - */ - public declare environment: 'production' | 'development' | 'beta'; - - /** - * Globally disabled commands. - */ - public declare disabledCommands: string[]; - - /** - * Globally blacklisted users. - */ - public declare blacklistedUsers: Snowflake[]; - - /** - * Guilds blacklisted from using the bot. - */ - public declare blacklistedGuilds: Snowflake[]; - - /** - * Channels where the bot is prevented from running commands in. - */ - public declare blacklistedChannels: Snowflake[]; - - /** - * Initializes the model. - * @param sequelize The sequelize instance. - */ - public static initModel(sequelize: Sequelize): void { - Global.init( - { - environment: { type: DataTypes.STRING, primaryKey: true }, - disabledCommands: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] }, - blacklistedUsers: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] }, - blacklistedGuilds: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] }, - blacklistedChannels: { type: DataTypes.JSONB, allowNull: false, defaultValue: [] } - }, - { sequelize } - ); - } -} diff --git a/src/lib/models/shared/GuildCount.ts b/src/lib/models/shared/GuildCount.ts deleted file mode 100644 index 51e571a..0000000 --- a/src/lib/models/shared/GuildCount.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { type Sequelize } from 'sequelize'; -import { Environment } from '../../../../config/Config.js'; -const { DataTypes, Model } = (await import('sequelize')).default; - -export interface GuildCountModel { - timestamp: Date; - environment: Environment; - guildCount: number; -} - -export interface GuildCountCreationAttributes { - timestamp?: Date; - environment: Environment; - guildCount: number; -} - -/** - * The number of guilds that the bot is in for each environment. - */ -export class GuildCount extends Model<GuildCountModel, GuildCountCreationAttributes> implements GuildCountModel { - public declare timestamp: Date; - public declare environment: Environment; - public declare guildCount: number; - - /** - * Initializes the model. - * @param sequelize The sequelize instance. - */ - public static initModel(sequelize: Sequelize): void { - GuildCount.init( - { - timestamp: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW }, - environment: { type: DataTypes.STRING, allowNull: false }, - guildCount: { type: DataTypes.BIGINT, allowNull: false } - }, - { sequelize, timestamps: false } - ); - } -} diff --git a/src/lib/models/shared/MemberCount.ts b/src/lib/models/shared/MemberCount.ts deleted file mode 100644 index ea8795c..0000000 --- a/src/lib/models/shared/MemberCount.ts +++ /dev/null @@ -1,38 +0,0 @@ -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 } - ); - } -} diff --git a/src/lib/models/shared/Shared.ts b/src/lib/models/shared/Shared.ts deleted file mode 100644 index 4d13011..0000000 --- a/src/lib/models/shared/Shared.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { Snowflake } from 'discord.js'; -import type { Sequelize } from 'sequelize'; -import type { BadWords } from '../../common/AutoMod.js'; -import { BaseModel } from '../BaseModel.js'; -const { DataTypes } = (await import('sequelize')).default; - -export interface SharedModel { - primaryKey: 0; - superUsers: Snowflake[]; - privilegedUsers: Snowflake[]; - badLinksSecret: string[]; - badLinks: string[]; - badWords: BadWords; - autoBanCode: string | null; -} - -export interface SharedModelCreationAttributes { - primaryKey?: 0; - superUsers?: Snowflake[]; - privilegedUsers?: Snowflake[]; - badLinksSecret?: string[]; - badLinks?: string[]; - badWords?: BadWords; - autoBanCode?: string; -} - -/** - * Data shared between all bot instances. - */ -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: Snowflake[]; - - /** - * 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; - - /** - * Code that is used to match for auto banning users in moulberry's bush - */ - public declare autoBanCode: 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: { 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: {} }, - autoBanCode: { type: DataTypes.TEXT } - }, - { sequelize, freezeTableName: true } - ); - } -} diff --git a/src/lib/models/shared/Stat.ts b/src/lib/models/shared/Stat.ts deleted file mode 100644 index 8e2e0b3..0000000 --- a/src/lib/models/shared/Stat.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { type Sequelize } from 'sequelize'; -import { BaseModel } from '../BaseModel.js'; -const { DataTypes } = (await import('sequelize')).default; - -type Environment = 'production' | 'development' | 'beta'; - -export interface StatModel { - environment: Environment; - commandsUsed: bigint; - slashCommandsUsed: bigint; -} - -export interface StatModelCreationAttributes { - environment: Environment; - commandsUsed?: bigint; - slashCommandsUsed?: bigint; -} - -/** - * Statistics for each instance of the bot. - */ -export class Stat extends BaseModel<StatModel, StatModelCreationAttributes> implements StatModel { - /** - * The bot's environment. - */ - public declare environment: Environment; - - /** - * The number of commands used - */ - public declare commandsUsed: bigint; - - /** - * The number of slash commands used - */ - public declare slashCommandsUsed: bigint; - - /** - * Initializes the model. - * @param sequelize The sequelize instance. - */ - public static initModel(sequelize: Sequelize): void { - Stat.init( - { - environment: { type: DataTypes.STRING, primaryKey: true }, - commandsUsed: { - type: DataTypes.TEXT, - get: function (): bigint { - return BigInt(this.getDataValue('commandsUsed')); - }, - set: function (val: bigint) { - return this.setDataValue('commandsUsed', <any>`${val}`); - }, - allowNull: false, - defaultValue: `${0n}` - }, - slashCommandsUsed: { - type: DataTypes.TEXT, - get: function (): bigint { - return BigInt(this.getDataValue('slashCommandsUsed')); - }, - set: function (val: bigint) { - return this.setDataValue('slashCommandsUsed', <any>`${val}`); - }, - allowNull: false, - defaultValue: `${0n}` - } - }, - { sequelize } - ); - } -} |