From edcc0dd0a9228192ff6c4f6d6797dd6238e98f92 Mon Sep 17 00:00:00 2001
From: IRONM00N <64110067+IRONM00N@users.noreply.github.com>
Date: Sat, 31 Jul 2021 13:46:27 -0400
Subject: upgraded to typescript 4.3.5
The reason I had to use getters and setters for the db models is because in the newer version of typescript the properties would be defined at runtime and override the getter and setters that sequalize uses later, causing all the values to be undefined and not being able to save any information.
---
src/lib/models/ActivePunishment.ts | 41 +++++++++++++---
src/lib/models/BaseModel.ts | 15 +++++-
src/lib/models/Global.ts | 36 +++++++++++---
src/lib/models/Guild.ts | 98 +++++++++++++++++++++++++++++++++-----
src/lib/models/Level.ts | 20 ++++++--
src/lib/models/ModLog.ts | 41 +++++++++++++---
src/lib/models/StickyRole.ts | 28 +++++++++--
7 files changed, 239 insertions(+), 40 deletions(-)
(limited to 'src/lib/models')
diff --git a/src/lib/models/ActivePunishment.ts b/src/lib/models/ActivePunishment.ts
index 9fcafbe..c204c9a 100644
--- a/src/lib/models/ActivePunishment.ts
+++ b/src/lib/models/ActivePunishment.ts
@@ -36,31 +36,58 @@ export class ActivePunishment
/**
* The ID of this punishment (no real use just for a primary key)
*/
- id: string;
+ public get id(): string {
+ return null;
+ }
+ public set id(value: string) {}
+
/**
* The type of punishment.
*/
- type: ActivePunishmentType;
+ public get type(): ActivePunishmentType {
+ return null;
+ }
+ public set type(value: ActivePunishmentType) {}
+
/**
* The user who is punished.
*/
- user: Snowflake;
+ public get user(): Snowflake {
+ return null;
+ }
+ public set user(value: Snowflake) {}
+
/**
* The guild they are punished in.
*/
- guild: Snowflake;
+ public get guild(): Snowflake {
+ return null;
+ }
+ public set guild(value: Snowflake) {}
+
/**
* Additional info about the punishment if applicable. The channel id for channel blocks and role for punishment roles.
*/
- extraInfo: Snowflake;
+ public get extraInfo(): Snowflake {
+ return null;
+ }
+ public set extraInfo(value: Snowflake) {}
+
/**
* The date when this punishment expires (optional).
*/
- expires: Date | null;
+ public get expires(): Date | null {
+ return null;
+ }
+ public set expires(value: Date | null) {}
+
/**
* The reference to the modlog entry.
*/
- modlog: string;
+ public get modlog(): string {
+ return null;
+ }
+ public set modlog(value: string) {}
static initModel(sequelize: Sequelize): void {
ActivePunishment.init(
diff --git a/src/lib/models/BaseModel.ts b/src/lib/models/BaseModel.ts
index fdbd706..340e0aa 100644
--- a/src/lib/models/BaseModel.ts
+++ b/src/lib/models/BaseModel.ts
@@ -1,6 +1,17 @@
import { Model } from 'sequelize';
export abstract class BaseModel extends Model {
- public readonly createdAt: Date;
- public readonly updatedAt: Date;
+ /**
+ * The date when the row was created.
+ */
+ public get createdAt(): Date {
+ return null;
+ }
+
+ /**
+ * The date when the row was last updated.
+ */
+ public get updatedAt(): Date {
+ return null;
+ }
}
diff --git a/src/lib/models/Global.ts b/src/lib/models/Global.ts
index e37ef2b..80f11ca 100644
--- a/src/lib/models/Global.ts
+++ b/src/lib/models/Global.ts
@@ -24,27 +24,51 @@ export class Global extends BaseModel implements GuildModel {
- id!: Snowflake;
- prefix!: string;
- autoPublishChannels: Snowflake[];
- blacklistedChannels: Snowflake[];
- blacklistedUsers: Snowflake[];
- welcomeChannel: Snowflake;
- muteRole: Snowflake;
- punishmentEnding: string;
- disabledCommands: string[];
- lockdownChannels: Snowflake[];
- autoModPhases: string[];
+ /**
+ * The ID of the guild
+ */
+ public get id(): Snowflake {
+ return null;
+ }
+ public set id(value: Snowflake) {}
+
+ /**
+ * The bot's prefix for the guild
+ */
+ public get prefix(): string {
+ return null;
+ }
+ public set prefix(value: string) {}
+
+ /**
+ * Channels that will have their messages automatically published
+ */
+ public get autoPublishChannels(): Snowflake[] {
+ return null;
+ }
+ public set autoPublishChannels(value: Snowflake[]) {}
+
+ /**
+ * Channels where the bot won't respond in.
+ */
+ public get blacklistedChannels(): Snowflake[] {
+ return null;
+ }
+ public set blacklistedChannels(value: Snowflake[]) {}
+
+ /**
+ * Users that the bot ignores in this guild
+ */
+ public get blacklistedUsers(): Snowflake[] {
+ return null;
+ }
+ public set blacklistedUsers(value: Snowflake[]) {}
+
+ /**
+ * The channels where the welcome messages are sent
+ */
+ public get welcomeChannel(): Snowflake {
+ return null;
+ }
+ public set welcomeChannel(value: Snowflake) {}
+
+ /**
+ * The role given out when muting someone
+ */
+ public get muteRole(): Snowflake {
+ return null;
+ }
+ public set muteRole(value: Snowflake) {}
+
+ /**
+ * The message that gets sent after someone gets a punishment dm
+ */
+ public get punishmentEnding(): string {
+ return null;
+ }
+ public set punishmentEnding(value: string) {}
+
+ /**
+ * Guild specific disabled commands
+ */
+ public get disabledCommands(): string[] {
+ return null;
+ }
+ public set disabledCommands(value: string[]) {}
+
+ /**
+ * Channels that should get locked down when the lockdown command gets used.
+ */
+ public get lockdownChannels(): Snowflake[] {
+ return null;
+ }
+ public set lockdownChannels(value: Snowflake[]) {}
+
+ /**
+ * Custom automod phases
+ */
+ public get autoModPhases(): string[] {
+ return null;
+ }
+ public set autoModPhases(value: string[]) {}
static initModel(sequelize: Sequelize, client: BushClient): void {
Guild.init(
diff --git a/src/lib/models/Level.ts b/src/lib/models/Level.ts
index 755b1c6..d8b98bf 100644
--- a/src/lib/models/Level.ts
+++ b/src/lib/models/Level.ts
@@ -18,16 +18,28 @@ export class Level extends BaseModel {
/**
* The user's id.
*/
- public user: Snowflake;
+ public get user(): Snowflake {
+ return null;
+ }
+ public set user(value: Snowflake) {}
+
/**
* The guild where the user is gaining xp.
*/
- public guild: Snowflake;
+ public get guild(): Snowflake {
+ return null;
+ }
+ public set guild(value: Snowflake) {}
+
/**
* The user's xp.
*/
- public xp: number;
- get level(): number {
+ public get xp(): number {
+ return null;
+ }
+ public set xp(value: number) {}
+
+ public get level(): number {
return Level.convertXpToLevel(this.xp);
}
diff --git a/src/lib/models/ModLog.ts b/src/lib/models/ModLog.ts
index 3375751..6933432 100644
--- a/src/lib/models/ModLog.ts
+++ b/src/lib/models/ModLog.ts
@@ -44,31 +44,58 @@ export class ModLog extends BaseModel implements StickyRoleModel {
- user: Snowflake;
- guild: Snowflake;
- roles: Snowflake[];
+ /**
+ * The id of the user the roles belongs to
+ */
+
+ public get user(): Snowflake {
+ return null;
+ }
+ public set user(value: Snowflake) {}
+
+ /**
+ * The guild where this should happen
+ */
+ public get guild(): Snowflake {
+ return null;
+ }
+ public set guild(value: Snowflake) {}
+
+ /**
+ * The roles that the user should have returned
+ */
+ public get roles(): Snowflake[] {
+ return null;
+ }
+ public set roles(value: Snowflake[]) {}
+
static initModel(sequelize: Sequelize): void {
StickyRole.init(
{
--
cgit