aboutsummaryrefslogtreecommitdiff
path: root/src/lib/models
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/models')
-rw-r--r--src/lib/models/Global.ts50
-rw-r--r--src/lib/models/Guild.ts16
-rw-r--r--src/lib/models/Level.ts2
-rw-r--r--src/lib/models/Modlog.ts2
-rw-r--r--src/lib/models/StickyRole.ts40
-rw-r--r--src/lib/models/index.ts6
6 files changed, 111 insertions, 5 deletions
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<GlobalModel, GlobalModelCreationAttributes> 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<GuildModel, 'prefix'>;
+
+export type GuildModelCreationAttributes = Optional<GuildModel, 'prefix' | 'autoPublishChannels' | 'blacklistedChannels'>;
export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> 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<GuildModel, GuildModelCreationAttributes> 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<LevelModel, LevelModelCreationAttributes> {
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<ModlogModel, ModlogModelCreationAttributes
// }
}
},
- { sequelize: sequelize }
+ { sequelize }
);
}
}
diff --git a/src/lib/models/StickyRole.ts b/src/lib/models/StickyRole.ts
new file mode 100644
index 0000000..597d7c5
--- /dev/null
+++ b/src/lib/models/StickyRole.ts
@@ -0,0 +1,40 @@
+import { Snowflake } from 'discord.js';
+import { DataTypes, Sequelize } from 'sequelize';
+import { BaseModel } from './BaseModel';
+
+export interface StickyRoleModel {
+ user: Snowflake;
+ guild: Snowflake;
+ roles: Snowflake[];
+}
+export interface StickyRoleModelCreationAttributes {
+ user: Snowflake;
+ guild: Snowflake;
+ roles: Snowflake[];
+}
+
+export class StickyRole extends BaseModel<StickyRoleModel, StickyRoleModelCreationAttributes> 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';