aboutsummaryrefslogtreecommitdiff
path: root/src/lib/models
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/models')
-rw-r--r--src/lib/models/ActivePunishment.ts32
-rw-r--r--src/lib/models/BaseModel.ts6
-rw-r--r--src/lib/models/Global.ts28
-rw-r--r--src/lib/models/Guild.ts50
-rw-r--r--src/lib/models/Level.ts19
-rw-r--r--src/lib/models/ModLog.ts50
-rw-r--r--src/lib/models/StickyRole.ts17
7 files changed, 117 insertions, 85 deletions
diff --git a/src/lib/models/ActivePunishment.ts b/src/lib/models/ActivePunishment.ts
index a757b10..fb2e79f 100644
--- a/src/lib/models/ActivePunishment.ts
+++ b/src/lib/models/ActivePunishment.ts
@@ -29,6 +29,8 @@ export interface ActivePunishmentModelCreationAttributes {
modlog: string;
}
+const NEVER_USED = 'This should never be executed';
+
export class ActivePunishment
extends BaseModel<ActivePunishmentModel, ActivePunishmentModelCreationAttributes>
implements ActivePunishmentModel
@@ -37,73 +39,73 @@ export class ActivePunishment
* The ID of this punishment (no real use just for a primary key)
*/
public get id(): string {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set id(_: string) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The type of punishment.
*/
public get type(): ActivePunishmentType {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set type(_: ActivePunishmentType) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The user who is punished.
*/
public get user(): Snowflake {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set user(_: Snowflake) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The guild they are punished in.
*/
public get guild(): Snowflake {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set guild(_: Snowflake) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* Additional info about the punishment if applicable. The channel id for channel blocks and role for punishment roles.
*/
public get extraInfo(): Snowflake {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set extraInfo(_: Snowflake) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The date when this punishment expires (optional).
*/
public get expires(): Date | null {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set expires(_: Date | null) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The reference to the modlog entry.
*/
public get modlog(): string {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set modlog(_: string) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
- static initModel(sequelize: Sequelize): void {
+ public static initModel(sequelize: Sequelize): void {
ActivePunishment.init(
{
id: {
diff --git a/src/lib/models/BaseModel.ts b/src/lib/models/BaseModel.ts
index f1521dd..8ed5ed3 100644
--- a/src/lib/models/BaseModel.ts
+++ b/src/lib/models/BaseModel.ts
@@ -1,17 +1,19 @@
import { Model } from 'sequelize';
+const NEVER_USED = 'This should never be executed';
+
export abstract class BaseModel<A, B> extends Model<A, B> {
/**
* The date when the row was created.
*/
public get createdAt(): Date {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The date when the row was last updated.
*/
public get updatedAt(): Date {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
}
diff --git a/src/lib/models/Global.ts b/src/lib/models/Global.ts
index a685d91..36c72d8 100644
--- a/src/lib/models/Global.ts
+++ b/src/lib/models/Global.ts
@@ -20,68 +20,70 @@ export interface GlobalModelCreationAttributes {
blacklistedChannels?: Snowflake[];
}
+const NEVER_USED = 'This should never be executed';
+
export class Global extends BaseModel<GlobalModel, GlobalModelCreationAttributes> implements GlobalModel {
/**
* The bot's environment.
*/
public get environment(): 'production' | 'development' | 'beta' {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set environment(_: 'production' | 'development' | 'beta') {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* Trusted users.
*/
public get superUsers(): Snowflake[] {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set superUsers(_: Snowflake[]) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* Globally disabled commands.
*/
public get disabledCommands(): string[] {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set disabledCommands(_: string[]) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* Globally blacklisted users.
*/
public get blacklistedUsers(): Snowflake[] {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set blacklistedUsers(_: Snowflake[]) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* Guilds blacklisted from using the bot.
*/
public get blacklistedGuilds(): Snowflake[] {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set blacklistedGuilds(_: Snowflake[]) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* Channels where the bot is prevented from running.
*/
public get blacklistedChannels(): Snowflake[] {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set blacklistedChannels(_: Snowflake[]) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
- static initModel(sequelize: Sequelize): void {
+ public static initModel(sequelize: Sequelize): void {
Global.init(
{
environment: {
diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts
index c28fe64..3473ea4 100644
--- a/src/lib/models/Guild.ts
+++ b/src/lib/models/Guild.ts
@@ -31,118 +31,120 @@ export interface GuildModelCreationAttributes {
autoModPhases?: string[];
}
+const NEVER_USED = 'This should never be executed';
+
export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> implements GuildModel {
/**
* The ID of the guild
*/
public get id(): Snowflake {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set id(_: Snowflake) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The bot's prefix for the guild
*/
public get prefix(): string {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set prefix(_: string) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* Channels that will have their messages automatically published
*/
public get autoPublishChannels(): Snowflake[] {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set autoPublishChannels(_: Snowflake[]) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* Channels where the bot won't respond in.
*/
public get blacklistedChannels(): Snowflake[] {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set blacklistedChannels(_: Snowflake[]) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* Users that the bot ignores in this guild
*/
public get blacklistedUsers(): Snowflake[] {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set blacklistedUsers(_: Snowflake[]) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The channels where the welcome messages are sent
*/
public get welcomeChannel(): Snowflake {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set welcomeChannel(_: Snowflake) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The role given out when muting someone
*/
public get muteRole(): Snowflake {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set muteRole(_: Snowflake) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The message that gets sent after someone gets a punishment dm
*/
public get punishmentEnding(): string {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set punishmentEnding(_: string) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* Guild specific disabled commands
*/
public get disabledCommands(): string[] {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set disabledCommands(_: string[]) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* Channels that should get locked down when the lockdown command gets used.
*/
public get lockdownChannels(): Snowflake[] {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set lockdownChannels(_: Snowflake[]) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* Custom automod phases
*/
public get autoModPhases(): string[] {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set autoModPhases(_: string[]) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
- static initModel(sequelize: Sequelize, client: BushClient): void {
+ public static initModel(sequelize: Sequelize, client: BushClient): void {
Guild.init(
{
id: {
@@ -150,7 +152,7 @@ export class Guild extends BaseModel<GuildModel, GuildModelCreationAttributes> i
primaryKey: true
},
prefix: {
- type: DataTypes.STRING,
+ type: DataTypes.TEXT,
allowNull: false,
defaultValue: client.config.prefix
},
diff --git a/src/lib/models/Level.ts b/src/lib/models/Level.ts
index 309e6e6..ad64747 100644
--- a/src/lib/models/Level.ts
+++ b/src/lib/models/Level.ts
@@ -14,42 +14,47 @@ export interface LevelModelCreationAttributes {
xp?: number;
}
+const NEVER_USED = 'This should never be executed';
+
export class Level extends BaseModel<LevelModel, LevelModelCreationAttributes> {
/**
* The user's id.
*/
public get user(): Snowflake {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set user(_: Snowflake) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The guild where the user is gaining xp.
*/
public get guild(): Snowflake {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set guild(_: Snowflake) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The user's xp.
*/
public get xp(): number {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set xp(_: number) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
+ /**
+ * The user's level.
+ */
public get level(): number {
return Level.convertXpToLevel(this.xp);
}
- static initModel(sequelize: Sequelize): void {
+ public static initModel(sequelize: Sequelize): void {
Level.init(
{
user: {
diff --git a/src/lib/models/ModLog.ts b/src/lib/models/ModLog.ts
index 33c758f..5da6027 100644
--- a/src/lib/models/ModLog.ts
+++ b/src/lib/models/ModLog.ts
@@ -28,6 +28,7 @@ export interface ModLogModel {
reason: string;
duration: number;
guild: Snowflake;
+ evidence: string;
}
export interface ModLogModelCreationAttributes {
@@ -38,80 +39,93 @@ export interface ModLogModelCreationAttributes {
reason?: string;
duration?: number;
guild: Snowflake;
+ evidence?: string;
}
+const NEVER_USED = 'This should never be executed';
+
export class ModLog extends BaseModel<ModLogModel, ModLogModelCreationAttributes> implements ModLogModel {
/**
* The primary key of the modlog entry.
*/
public get id(): string {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set id(_: string) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The type of punishment.
*/
public get type(): ModLogType {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set type(_: ModLogType) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The user being punished.
*/
public get user(): Snowflake {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set user(_: Snowflake) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The user carrying out the punishment.
*/
public get moderator(): Snowflake {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set moderator(_: Snowflake) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The reason the user is getting punished
*/
public get reason(): string | null {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set reason(_: string | null) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The amount of time the user is getting punished for.
*/
public get duration(): number | null {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set duration(_: number | null) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The guild the user is getting punished in.
*/
public get guild(): Snowflake {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set guild(_: Snowflake) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
- static initModel(sequelize: Sequelize): void {
+ /**
+ * Evidence of what the user is getting punished for.
+ */
+ public get evidence(): string {
+ throw new Error(NEVER_USED);
+ }
+ public set evidence(_: string) {
+ throw new Error(NEVER_USED);
+ }
+
+ public static initModel(sequelize: Sequelize): void {
ModLog.init(
{
id: {
@@ -137,7 +151,7 @@ export class ModLog extends BaseModel<ModLogModel, ModLogModelCreationAttributes
allowNull: true
},
reason: {
- type: DataTypes.STRING,
+ type: DataTypes.TEXT,
allowNull: true
},
guild: {
@@ -146,6 +160,10 @@ export class ModLog extends BaseModel<ModLogModel, ModLogModelCreationAttributes
model: 'Guilds',
key: 'id'
}
+ },
+ evidence: {
+ type: DataTypes.TEXT,
+ allowNull: true
}
},
{ sequelize: sequelize }
diff --git a/src/lib/models/StickyRole.ts b/src/lib/models/StickyRole.ts
index 46650a4..b49af80 100644
--- a/src/lib/models/StickyRole.ts
+++ b/src/lib/models/StickyRole.ts
@@ -13,39 +13,40 @@ export interface StickyRoleModelCreationAttributes {
roles: Snowflake[];
}
+const NEVER_USED = 'This should never be executed';
+
export class StickyRole extends BaseModel<StickyRoleModel, StickyRoleModelCreationAttributes> implements StickyRoleModel {
/**
* The id of the user the roles belongs to
*/
-
public get user(): Snowflake {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set user(_: Snowflake) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The guild where this should happen
*/
public get guild(): Snowflake {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set guild(_: Snowflake) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
/**
* The roles that the user should have returned
*/
public get roles(): Snowflake[] {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
public set roles(_: Snowflake[]) {
- throw new Error('This should never be executed');
+ throw new Error(NEVER_USED);
}
- static initModel(sequelize: Sequelize): void {
+ public static initModel(sequelize: Sequelize): void {
StickyRole.init(
{
user: {