From 534aed7f7cd700cc83a9d61f928bba6628e05c86 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sat, 31 Jul 2021 13:58:38 -0400 Subject: throw error objects instead of strings --- src/lib/models/ActivePunishment.ts | 42 ++++++++++++++++-------- src/lib/models/BaseModel.ts | 4 +-- src/lib/models/Global.ts | 36 ++++++++++++++------- src/lib/models/Guild.ts | 66 +++++++++++++++++++++++++------------- src/lib/models/Level.ts | 18 +++++++---- src/lib/models/ModLog.ts | 42 ++++++++++++++++-------- src/lib/models/StickyRole.ts | 18 +++++++---- 7 files changed, 150 insertions(+), 76 deletions(-) (limited to 'src/lib/models') diff --git a/src/lib/models/ActivePunishment.ts b/src/lib/models/ActivePunishment.ts index c204c9a..a757b10 100644 --- a/src/lib/models/ActivePunishment.ts +++ b/src/lib/models/ActivePunishment.ts @@ -37,57 +37,71 @@ export class ActivePunishment * The ID of this punishment (no real use just for a primary key) */ public get id(): string { - return null; + throw new Error('This should never be executed'); + } + public set id(_: string) { + throw new Error('This should never be executed'); } - public set id(value: string) {} /** * The type of punishment. */ public get type(): ActivePunishmentType { - return null; + throw new Error('This should never be executed'); + } + public set type(_: ActivePunishmentType) { + throw new Error('This should never be executed'); } - public set type(value: ActivePunishmentType) {} /** * The user who is punished. */ public get user(): Snowflake { - return null; + throw new Error('This should never be executed'); + } + public set user(_: Snowflake) { + throw new Error('This should never be executed'); } - public set user(value: Snowflake) {} /** * The guild they are punished in. */ public get guild(): Snowflake { - return null; + throw new Error('This should never be executed'); + } + public set guild(_: Snowflake) { + throw new Error('This should never be executed'); } - public set guild(value: Snowflake) {} /** * Additional info about the punishment if applicable. The channel id for channel blocks and role for punishment roles. */ public get extraInfo(): Snowflake { - return null; + throw new Error('This should never be executed'); + } + public set extraInfo(_: Snowflake) { + throw new Error('This should never be executed'); } - public set extraInfo(value: Snowflake) {} /** * The date when this punishment expires (optional). */ public get expires(): Date | null { - return null; + throw new Error('This should never be executed'); + } + public set expires(_: Date | null) { + throw new Error('This should never be executed'); } - public set expires(value: Date | null) {} /** * The reference to the modlog entry. */ public get modlog(): string { - return null; + throw new Error('This should never be executed'); + } + public set modlog(_: string) { + throw new Error('This should never be executed'); } - 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 340e0aa..f1521dd 100644 --- a/src/lib/models/BaseModel.ts +++ b/src/lib/models/BaseModel.ts @@ -5,13 +5,13 @@ export abstract class BaseModel extends Model { * The date when the row was created. */ public get createdAt(): Date { - return null; + throw new Error('This should never be executed'); } /** * The date when the row was last updated. */ public get updatedAt(): Date { - return null; + throw new Error('This should never be executed'); } } diff --git a/src/lib/models/Global.ts b/src/lib/models/Global.ts index 80f11ca..a685d91 100644 --- a/src/lib/models/Global.ts +++ b/src/lib/models/Global.ts @@ -25,49 +25,61 @@ export class Global extends BaseModel i * The ID of the guild */ public get id(): Snowflake { - return null; + throw new Error('This should never be executed'); + } + public set id(_: Snowflake) { + throw new Error('This should never be executed'); } - public set id(value: Snowflake) {} /** * The bot's prefix for the guild */ public get prefix(): string { - return null; + throw new Error('This should never be executed'); + } + public set prefix(_: string) { + throw new Error('This should never be executed'); } - public set prefix(value: string) {} /** * Channels that will have their messages automatically published */ public get autoPublishChannels(): Snowflake[] { - return null; + throw new Error('This should never be executed'); + } + public set autoPublishChannels(_: Snowflake[]) { + throw new Error('This should never be executed'); } - public set autoPublishChannels(value: Snowflake[]) {} /** * Channels where the bot won't respond in. */ public get blacklistedChannels(): Snowflake[] { - return null; + throw new Error('This should never be executed'); + } + public set blacklistedChannels(_: Snowflake[]) { + throw new Error('This should never be executed'); } - public set blacklistedChannels(value: Snowflake[]) {} /** * Users that the bot ignores in this guild */ public get blacklistedUsers(): Snowflake[] { - return null; + throw new Error('This should never be executed'); + } + public set blacklistedUsers(_: Snowflake[]) { + throw new Error('This should never be executed'); } - public set blacklistedUsers(value: Snowflake[]) {} /** * The channels where the welcome messages are sent */ public get welcomeChannel(): Snowflake { - return null; + throw new Error('This should never be executed'); + } + public set welcomeChannel(_: Snowflake) { + throw new Error('This should never be executed'); } - public set welcomeChannel(value: Snowflake) {} /** * The role given out when muting someone */ public get muteRole(): Snowflake { - return null; + throw new Error('This should never be executed'); + } + public set muteRole(_: Snowflake) { + throw new Error('This should never be executed'); } - public set muteRole(value: Snowflake) {} /** * The message that gets sent after someone gets a punishment dm */ public get punishmentEnding(): string { - return null; + throw new Error('This should never be executed'); + } + public set punishmentEnding(_: string) { + throw new Error('This should never be executed'); } - public set punishmentEnding(value: string) {} /** * Guild specific disabled commands */ public get disabledCommands(): string[] { - return null; + throw new Error('This should never be executed'); + } + public set disabledCommands(_: string[]) { + throw new Error('This should never be executed'); } - public set disabledCommands(value: string[]) {} /** * Channels that should get locked down when the lockdown command gets used. */ public get lockdownChannels(): Snowflake[] { - return null; + throw new Error('This should never be executed'); + } + public set lockdownChannels(_: Snowflake[]) { + throw new Error('This should never be executed'); } - public set lockdownChannels(value: Snowflake[]) {} /** * Custom automod phases */ public get autoModPhases(): string[] { - return null; + throw new Error('This should never be executed'); + } + public set autoModPhases(_: string[]) { + throw new Error('This should never be executed'); } - 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 d8b98bf..309e6e6 100644 --- a/src/lib/models/Level.ts +++ b/src/lib/models/Level.ts @@ -19,25 +19,31 @@ export class Level extends BaseModel { * The user's id. */ public get user(): Snowflake { - return null; + throw new Error('This should never be executed'); + } + public set user(_: Snowflake) { + throw new Error('This should never be executed'); } - public set user(value: Snowflake) {} /** * The guild where the user is gaining xp. */ public get guild(): Snowflake { - return null; + throw new Error('This should never be executed'); + } + public set guild(_: Snowflake) { + throw new Error('This should never be executed'); } - public set guild(value: Snowflake) {} /** * The user's xp. */ public get xp(): number { - return null; + throw new Error('This should never be executed'); + } + public set xp(_: number) { + throw new Error('This should never be executed'); } - 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 6933432..33c758f 100644 --- a/src/lib/models/ModLog.ts +++ b/src/lib/models/ModLog.ts @@ -45,57 +45,71 @@ export class ModLog extends BaseModel