From 5c3da90f441c321f55ae735d6002f4da91f2481e Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 20 Jun 2021 22:52:50 -0400 Subject: feat(*): aaaaa --- src/lib/models/Global.ts | 50 ++++++++++++++++++++++++++++++++++++++++++++ src/lib/models/Guild.ts | 16 +++++++++++++- src/lib/models/Level.ts | 2 +- src/lib/models/Modlog.ts | 2 +- src/lib/models/StickyRole.ts | 40 +++++++++++++++++++++++++++++++++++ src/lib/models/index.ts | 6 ++++-- 6 files changed, 111 insertions(+), 5 deletions(-) create mode 100644 src/lib/models/Global.ts create mode 100644 src/lib/models/StickyRole.ts (limited to 'src/lib/models') diff --git a/src/lib/models/Global.ts b/src/lib/models/Global.ts new file mode 100644 index 0000000..65f51c4 --- /dev/null +++ b/src/lib/models/Global.ts @@ -0,0 +1,50 @@ +import { Snowflake } from 'discord.js'; +import { DataTypes, Optional, Sequelize } from 'sequelize'; +import { BaseModel } from './BaseModel'; + +export interface GlobalModel { + superUsers: Snowflake[]; + disabledCommands: string[]; + blacklistedUsers: Snowflake[]; + blacklistedGuilds: Snowflake[]; + blacklistedChannels: Snowflake[]; +} +export type GlobalModelCreationAttributes = Optional< + GlobalModel, + 'superUsers' | 'disabledCommands' | 'blacklistedUsers' | 'blacklistedGuilds' | 'blacklistedChannels' +>; + +export class Global extends BaseModel implements GlobalModel { + superUsers: Snowflake[]; + disabledCommands: string[]; + blacklistedUsers: Snowflake[]; + blacklistedGuilds: Snowflake[]; + blacklistedChannels: Snowflake[]; + static initModel(sequelize: Sequelize): void { + Global.init( + { + superUsers: { + type: DataTypes.ARRAY(DataTypes.STRING), + allowNull: true + }, + disabledCommands: { + type: DataTypes.ARRAY(DataTypes.STRING), + allowNull: true + }, + blacklistedUsers: { + type: DataTypes.ARRAY(DataTypes.STRING), + allowNull: true + }, + blacklistedGuilds: { + type: DataTypes.ARRAY(DataTypes.STRING), + allowNull: true + }, + blacklistedChannels: { + type: DataTypes.ARRAY(DataTypes.STRING), + allowNull: true + } + }, + { sequelize } + ); + } +} diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts index 7902461..bc93951 100644 --- a/src/lib/models/Guild.ts +++ b/src/lib/models/Guild.ts @@ -1,3 +1,4 @@ +import { Snowflake } from 'discord.js'; import { DataTypes, Optional, Sequelize } from 'sequelize'; import { BushClient } from '../extensions/BushClient'; import { BaseModel } from './BaseModel'; @@ -5,12 +6,17 @@ import { BaseModel } from './BaseModel'; export interface GuildModel { id: string; prefix: string; + autoPublishChannels: string[]; + blacklistedChannels: Snowflake[]; } -export type GuildModelCreationAttributes = Optional; + +export type GuildModelCreationAttributes = Optional; export class Guild extends BaseModel implements GuildModel { id: string; prefix: string; + autoPublishChannels: string[]; + blacklistedChannels: Snowflake[]; static initModel(seqeulize: Sequelize, client: BushClient): void { Guild.init( { @@ -22,6 +28,14 @@ export class Guild extends BaseModel i type: DataTypes.STRING, allowNull: false, defaultValue: client.config.prefix + }, + autoPublishChannels: { + type: DataTypes.ARRAY(DataTypes.STRING), + allowNull: true + }, + blacklistedChannels: { + type: DataTypes.ARRAY(DataTypes.STRING), + allowNull: true } }, { sequelize: seqeulize } diff --git a/src/lib/models/Level.ts b/src/lib/models/Level.ts index 426ec1a..6113627 100644 --- a/src/lib/models/Level.ts +++ b/src/lib/models/Level.ts @@ -32,7 +32,7 @@ export class Level extends BaseModel { defaultValue: 0 } }, - { sequelize: sequelize } + { sequelize } ); } static convertXpToLevel(xp: number): number { diff --git a/src/lib/models/Modlog.ts b/src/lib/models/Modlog.ts index 5a2cb69..15c5030 100644 --- a/src/lib/models/Modlog.ts +++ b/src/lib/models/Modlog.ts @@ -77,7 +77,7 @@ export class Modlog extends BaseModel implements StickyRoleModel { + user: Snowflake; + guild: Snowflake; + roles: Snowflake[]; + static initModel(sequelize: Sequelize): void { + StickyRole.init( + { + user: { + type: DataTypes.STRING, + allowNull: false + }, + guild: { + type: DataTypes.STRING, + allowNull: false + }, + + roles: { + type: DataTypes.ARRAY(DataTypes.STRING), + allowNull: false + } + }, + { sequelize } + ); + } +} diff --git a/src/lib/models/index.ts b/src/lib/models/index.ts index 8eb817e..e38ad69 100644 --- a/src/lib/models/index.ts +++ b/src/lib/models/index.ts @@ -1,5 +1,7 @@ +export * from './Ban'; export * from './BaseModel'; +export * from './Global'; export * from './Guild'; -export * from './Ban'; -export * from './Modlog'; export * from './Level'; +export * from './Modlog'; +export * from './StickyRole'; -- cgit