aboutsummaryrefslogtreecommitdiff
path: root/src/lib/models
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-17 10:25:46 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-17 10:25:46 -0400
commitd1724227abfb8f0fcd9e573f7e9772cf0be8257a (patch)
tree52c9dbae1fbbbd3c777d9c16ab643c477141ae21 /src/lib/models
parent53d2b18f7f73d5696fb7cd86d1c164a790dfdcc3 (diff)
downloadtanzanite-d1724227abfb8f0fcd9e573f7e9772cf0be8257a.tar.gz
tanzanite-d1724227abfb8f0fcd9e573f7e9772cf0be8257a.tar.bz2
tanzanite-d1724227abfb8f0fcd9e573f7e9772cf0be8257a.zip
honestly no idea what I did at this point
Diffstat (limited to 'src/lib/models')
-rw-r--r--src/lib/models/Global.ts15
-rw-r--r--src/lib/models/Guild.ts48
-rw-r--r--src/lib/models/Level.ts19
3 files changed, 70 insertions, 12 deletions
diff --git a/src/lib/models/Global.ts b/src/lib/models/Global.ts
index ba77302..8664365 100644
--- a/src/lib/models/Global.ts
+++ b/src/lib/models/Global.ts
@@ -60,7 +60,8 @@ export class Global extends BaseModel<GlobalModel, GlobalModelCreationAttributes
set: function (val: Snowflake[]) {
return this.setDataValue('superUsers', JSON.stringify(val) as unknown as Snowflake[]);
},
- allowNull: true
+ allowNull: false,
+ defaultValue: '[]'
},
disabledCommands: {
type: DataTypes.STRING,
@@ -70,7 +71,8 @@ export class Global extends BaseModel<GlobalModel, GlobalModelCreationAttributes
set: function (val: Snowflake[]) {
return this.setDataValue('disabledCommands', JSON.stringify(val) as unknown as string[]);
},
- allowNull: true
+ allowNull: false,
+ defaultValue: '[]'
},
blacklistedUsers: {
type: DataTypes.STRING,
@@ -80,7 +82,8 @@ export class Global extends BaseModel<GlobalModel, GlobalModelCreationAttributes
set: function (val: Snowflake[]) {
return this.setDataValue('blacklistedUsers', JSON.stringify(val) as unknown as Snowflake[]);
},
- allowNull: true
+ allowNull: false,
+ defaultValue: '[]'
},
blacklistedGuilds: {
type: DataTypes.STRING,
@@ -90,7 +93,8 @@ export class Global extends BaseModel<GlobalModel, GlobalModelCreationAttributes
set: function (val: Snowflake[]) {
return this.setDataValue('blacklistedGuilds', JSON.stringify(val) as unknown as Snowflake[]);
},
- allowNull: true
+ allowNull: false,
+ defaultValue: '[]'
},
blacklistedChannels: {
type: DataTypes.STRING,
@@ -100,7 +104,8 @@ export class Global extends BaseModel<GlobalModel, GlobalModelCreationAttributes
set: function (val: Snowflake[]) {
return this.setDataValue('blacklistedChannels', JSON.stringify(val) as unknown as Snowflake[]);
},
- allowNull: true
+ allowNull: false,
+ defaultValue: '[]'
}
},
{ sequelize: sequelize }
diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts
index 43fcd64..30072b3 100644
--- a/src/lib/models/Guild.ts
+++ b/src/lib/models/Guild.ts
@@ -8,9 +8,12 @@ export interface GuildModel {
prefix: string;
autoPublishChannels: Snowflake[];
blacklistedChannels: Snowflake[];
+ blacklistedUsers: Snowflake[];
welcomeChannel: Snowflake;
muteRole: Snowflake;
punishmentEnding: string;
+ disabledCommands: string[];
+ lockdownChannels: Snowflake[];
}
export interface GuildModelCreationAttributes {
@@ -18,9 +21,12 @@ export interface GuildModelCreationAttributes {
prefix?: string;
autoPublishChannels?: Snowflake[];
blacklistedChannels?: Snowflake[];
+ blacklistedUsers?: Snowflake[];
welcomeChannel?: Snowflake;
muteRole?: Snowflake;
punishmentEnding?: string;
+ disabledCommands?: string[];
+ lockdownChannels?: Snowflake[];
}
export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> implements GuildModel {
@@ -28,9 +34,12 @@ export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> i
prefix!: string;
autoPublishChannels: Snowflake[];
blacklistedChannels: Snowflake[];
+ blacklistedUsers: Snowflake[];
welcomeChannel: Snowflake;
muteRole: Snowflake;
punishmentEnding: string;
+ disabledCommands: string[];
+ lockdownChannels: Snowflake[];
static initModel(sequelize: Sequelize, client: BushClient): void {
Guild.init(
@@ -52,7 +61,8 @@ export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> i
set: function (val: Snowflake[]) {
return this.setDataValue('autoPublishChannels', JSON.stringify(val) as unknown as Snowflake[]);
},
- allowNull: true
+ allowNull: false,
+ defaultValue: '[]'
},
blacklistedChannels: {
type: DataTypes.STRING,
@@ -62,7 +72,19 @@ export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> i
set: function (val: Snowflake[]) {
return this.setDataValue('blacklistedChannels', JSON.stringify(val) as unknown as Snowflake[]);
},
- allowNull: true
+ allowNull: false,
+ defaultValue: '[]'
+ },
+ blacklistedUsers: {
+ 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: false,
+ defaultValue: '[]'
},
welcomeChannel: {
type: DataTypes.STRING,
@@ -75,6 +97,28 @@ export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> i
punishmentEnding: {
type: DataTypes.TEXT,
allowNull: true
+ },
+ disabledCommands: {
+ type: DataTypes.STRING,
+ get: function () {
+ return JSON.parse(this.getDataValue('disabledCommands') as unknown as string);
+ },
+ set: function (val: string[]) {
+ return this.setDataValue('disabledCommands', JSON.stringify(val) as unknown as string[]);
+ },
+ allowNull: false,
+ defaultValue: '[]'
+ },
+ lockdownChannels: {
+ type: DataTypes.STRING,
+ get: function () {
+ return JSON.parse(this.getDataValue('lockdownChannels') as unknown as string);
+ },
+ set: function (val: Snowflake[]) {
+ return this.setDataValue('lockdownChannels', JSON.stringify(val) as unknown as Snowflake[]);
+ },
+ allowNull: false,
+ defaultValue: '[]'
}
},
{ sequelize: sequelize }
diff --git a/src/lib/models/Level.ts b/src/lib/models/Level.ts
index b834992..755b1c6 100644
--- a/src/lib/models/Level.ts
+++ b/src/lib/models/Level.ts
@@ -3,12 +3,14 @@ import { DataTypes, Sequelize } from 'sequelize';
import { BaseModel } from './BaseModel';
export interface LevelModel {
- id: Snowflake;
+ user: Snowflake;
+ guild: Snowflake;
xp: number;
}
export interface LevelModelCreationAttributes {
- id: Snowflake;
+ user: Snowflake;
+ guild: Snowflake;
xp?: number;
}
@@ -16,7 +18,11 @@ export class Level extends BaseModel<LevelModel, LevelModelCreationAttributes> {
/**
* The user's id.
*/
- public id: Snowflake;
+ public user: Snowflake;
+ /**
+ * The guild where the user is gaining xp.
+ */
+ public guild: Snowflake;
/**
* The user's xp.
*/
@@ -28,9 +34,12 @@ export class Level extends BaseModel<LevelModel, LevelModelCreationAttributes> {
static initModel(sequelize: Sequelize): void {
Level.init(
{
- id: {
+ user: {
+ type: DataTypes.STRING,
+ allowNull: false
+ },
+ guild: {
type: DataTypes.STRING,
- primaryKey: true,
allowNull: false
},
xp: {