aboutsummaryrefslogtreecommitdiff
path: root/src/lib/models
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-06-21 15:33:36 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-06-21 15:33:36 -0400
commit6eb42974bdd4da4f9a6d77c8fde4c19f9f0a351b (patch)
tree6b0490f7f17d5d663f0f764589328e8acb79dd22 /src/lib/models
parent5c3da90f441c321f55ae735d6002f4da91f2481e (diff)
downloadtanzanite-6eb42974bdd4da4f9a6d77c8fde4c19f9f0a351b.tar.gz
tanzanite-6eb42974bdd4da4f9a6d77c8fde4c19f9f0a351b.tar.bz2
tanzanite-6eb42974bdd4da4f9a6d77c8fde4c19f9f0a351b.zip
fix(db): made it work now
Diffstat (limited to 'src/lib/models')
-rw-r--r--src/lib/models/Global.ts46
-rw-r--r--src/lib/models/Guild.ts16
-rw-r--r--src/lib/models/Level.ts2
-rw-r--r--src/lib/models/StickyRole.ts10
4 files changed, 64 insertions, 10 deletions
diff --git a/src/lib/models/Global.ts b/src/lib/models/Global.ts
index 65f51c4..abe0ab3 100644
--- a/src/lib/models/Global.ts
+++ b/src/lib/models/Global.ts
@@ -3,6 +3,7 @@ import { DataTypes, Optional, Sequelize } from 'sequelize';
import { BaseModel } from './BaseModel';
export interface GlobalModel {
+ environment: 'production' | 'development';
superUsers: Snowflake[];
disabledCommands: string[];
blacklistedUsers: Snowflake[];
@@ -15,6 +16,7 @@ export type GlobalModelCreationAttributes = Optional<
>;
export class Global extends BaseModel<GlobalModel, GlobalModelCreationAttributes> implements GlobalModel {
+ environment: 'production' | 'development';
superUsers: Snowflake[];
disabledCommands: string[];
blacklistedUsers: Snowflake[];
@@ -23,24 +25,58 @@ export class Global extends BaseModel<GlobalModel, GlobalModelCreationAttributes
static initModel(sequelize: Sequelize): void {
Global.init(
{
+ environment: {
+ type: DataTypes.STRING,
+ primaryKey: true
+ },
superUsers: {
- type: DataTypes.ARRAY(DataTypes.STRING),
+ type: DataTypes.STRING,
+ get: function () {
+ return JSON.parse(this.getDataValue('superUsers') as unknown as string);
+ },
+ set: function (val: Snowflake[]) {
+ return this.setDataValue('superUsers', JSON.stringify(val) as unknown as Snowflake[]);
+ },
allowNull: true
},
disabledCommands: {
- type: DataTypes.ARRAY(DataTypes.STRING),
+ type: DataTypes.STRING,
+ get: function () {
+ return JSON.parse(this.getDataValue('disabledCommands') as unknown as string);
+ },
+ set: function (val: Snowflake[]) {
+ return this.setDataValue('disabledCommands', JSON.stringify(val) as unknown as string[]);
+ },
allowNull: true
},
blacklistedUsers: {
- type: DataTypes.ARRAY(DataTypes.STRING),
+ type: DataTypes.STRING,
+ get: function () {
+ return JSON.parse(this.getDataValue('blacklistedUsers') as unknown as string);
+ },
+ set: function (val: Snowflake[]) {
+ return this.setDataValue('blacklistedUsers', JSON.stringify(val) as unknown as Snowflake[]);
+ },
allowNull: true
},
blacklistedGuilds: {
- type: DataTypes.ARRAY(DataTypes.STRING),
+ type: DataTypes.STRING,
+ get: function () {
+ return JSON.parse(this.getDataValue('blacklistedGuilds') as unknown as string);
+ },
+ set: function (val: Snowflake[]) {
+ return this.setDataValue('blacklistedGuilds', JSON.stringify(val) as unknown as Snowflake[]);
+ },
allowNull: true
},
blacklistedChannels: {
- type: DataTypes.ARRAY(DataTypes.STRING),
+ type: DataTypes.STRING,
+ get: function () {
+ return JSON.parse(this.getDataValue('blacklistedChannels') as unknown as string);
+ },
+ set: function (val: Snowflake[]) {
+ return this.setDataValue('blacklistedChannels', JSON.stringify(val) as unknown as Snowflake[]);
+ },
allowNull: true
}
},
diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts
index bc93951..c4ae53e 100644
--- a/src/lib/models/Guild.ts
+++ b/src/lib/models/Guild.ts
@@ -30,11 +30,23 @@ export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> i
defaultValue: client.config.prefix
},
autoPublishChannels: {
- type: DataTypes.ARRAY(DataTypes.STRING),
+ type: DataTypes.STRING,
+ get: function () {
+ return JSON.parse(this.getDataValue('autoPublishChannels') as unknown as string);
+ },
+ set: function (val: Snowflake[]) {
+ return this.setDataValue('autoPublishChannels', JSON.stringify(val) as unknown as Snowflake[]);
+ },
allowNull: true
},
blacklistedChannels: {
- type: DataTypes.ARRAY(DataTypes.STRING),
+ type: DataTypes.STRING,
+ get: function () {
+ return JSON.parse(this.getDataValue('blacklistedChannels') as unknown as string);
+ },
+ set: function (val: Snowflake[]) {
+ return this.setDataValue('blacklistedChannels', JSON.stringify(val) as unknown as Snowflake[]);
+ },
allowNull: true
}
},
diff --git a/src/lib/models/Level.ts b/src/lib/models/Level.ts
index 6113627..426ec1a 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/StickyRole.ts b/src/lib/models/StickyRole.ts
index 597d7c5..a3928e7 100644
--- a/src/lib/models/StickyRole.ts
+++ b/src/lib/models/StickyRole.ts
@@ -30,8 +30,14 @@ export class StickyRole extends BaseModel<StickyRoleModel, StickyRoleModelCreati
},
roles: {
- type: DataTypes.ARRAY(DataTypes.STRING),
- allowNull: false
+ type: DataTypes.STRING,
+ get: function () {
+ return JSON.parse(this.getDataValue('roles') as unknown as string);
+ },
+ set: function (val: Snowflake[]) {
+ return this.setDataValue('roles', JSON.stringify(val) as unknown as Snowflake[]);
+ },
+ allowNull: true
}
},
{ sequelize }