From 6eb42974bdd4da4f9a6d77c8fde4c19f9f0a351b Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Mon, 21 Jun 2021 15:33:36 -0400 Subject: fix(db): made it work now --- src/lib/models/Global.ts | 46 +++++++++++++++++++++++++++++++++++++++----- src/lib/models/Guild.ts | 16 +++++++++++++-- src/lib/models/Level.ts | 2 +- src/lib/models/StickyRole.ts | 10 ++++++++-- 4 files changed, 64 insertions(+), 10 deletions(-) (limited to 'src/lib/models') 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 implements GlobalModel { + environment: 'production' | 'development'; superUsers: Snowflake[]; disabledCommands: string[]; blacklistedUsers: Snowflake[]; @@ -23,24 +25,58 @@ export class Global extends BaseModel 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 { 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