From 070b5f326d0647e7b105f99811e4bdc915c8652e Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Wed, 14 Jul 2021 13:12:32 -0400 Subject: revamped role command and some other stuff --- src/lib/models/Ban.ts | 8 ++++---- src/lib/models/Global.ts | 33 ++++++++++++++++++++++++++++----- src/lib/models/Guild.ts | 23 ++++++++++++++++------- src/lib/models/Level.ts | 13 ++++++++++--- src/lib/models/ModLog.ts | 21 +++++++++++++++++++++ src/lib/models/Mute.ts | 8 ++++---- src/lib/models/PunishmentRole.ts | 18 ++++++++++++++---- 7 files changed, 97 insertions(+), 27 deletions(-) (limited to 'src/lib/models') diff --git a/src/lib/models/Ban.ts b/src/lib/models/Ban.ts index 54ca6ae..1bdda6f 100644 --- a/src/lib/models/Ban.ts +++ b/src/lib/models/Ban.ts @@ -5,15 +5,15 @@ import { BaseModel } from './BaseModel'; export interface BanModel { id: string; - user: string; - guild: string; + user: Snowflake; + guild: Snowflake; expires: Date; modlog: string; } export interface BanModelCreationAttributes { id?: string; - user: string; - guild: string; + user: Snowflake; + guild: Snowflake; expires?: Date; modlog: string; } diff --git a/src/lib/models/Global.ts b/src/lib/models/Global.ts index 842f14b..ba77302 100644 --- a/src/lib/models/Global.ts +++ b/src/lib/models/Global.ts @@ -1,5 +1,5 @@ import { Snowflake } from 'discord.js'; -import { DataTypes, Optional, Sequelize } from 'sequelize'; +import { DataTypes, Sequelize } from 'sequelize'; import { BaseModel } from './BaseModel'; export interface GlobalModel { @@ -10,17 +10,40 @@ export interface GlobalModel { blacklistedGuilds: Snowflake[]; blacklistedChannels: Snowflake[]; } -export type GlobalModelCreationAttributes = Optional< - GlobalModel, - 'superUsers' | 'disabledCommands' | 'blacklistedUsers' | 'blacklistedGuilds' | 'blacklistedChannels' ->; + +export interface GlobalModelCreationAttributes { + environment: 'production' | 'development'; + superUsers?: Snowflake[]; + disabledCommands?: string[]; + blacklistedUsers?: Snowflake[]; + blacklistedGuilds?: Snowflake[]; + blacklistedChannels?: Snowflake[]; +} export class Global extends BaseModel implements GlobalModel { + /** + * The bot's environment. + */ environment: 'production' | 'development'; + /** + * Trusted users. + */ superUsers: Snowflake[]; + /** + * Globally disabled commands. + */ disabledCommands: string[]; + /** + * Globally blacklisted users. + */ blacklistedUsers: Snowflake[]; + /** + * Guilds blacklisted from using the bot. + */ blacklistedGuilds: Snowflake[]; + /** + * Channels where the bot is prevented from running. + */ blacklistedChannels: Snowflake[]; static initModel(sequelize: Sequelize): void { Global.init( diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts index 0fc3413..f6aa1a4 100644 --- a/src/lib/models/Guild.ts +++ b/src/lib/models/Guild.ts @@ -1,5 +1,5 @@ import { Snowflake } from 'discord.js'; -import { DataTypes, Optional, Sequelize } from 'sequelize'; +import { DataTypes, Sequelize } from 'sequelize'; import { BushClient } from '../extensions/discord-akairo/BushClient'; import { BaseModel } from './BaseModel'; @@ -13,14 +13,23 @@ export interface GuildModel { punishmentEnding: string; } -export type GuildModelCreationAttributes = Optional< - GuildModel, - 'prefix' | 'autoPublishChannels' | 'blacklistedChannels' | 'welcomeChannel' | 'muteRole' | 'punishmentEnding' ->; +// export type GuildModelCreationAttributes = Optional< +// GuildModel, +// 'prefix' | 'autoPublishChannels' | 'blacklistedChannels' | 'welcomeChannel' | 'muteRole' | 'punishmentEnding' +// >; +export interface GuildModelCreationAttributes { + id: string; + prefix?: string; + autoPublishChannels?: Snowflake[]; + blacklistedChannels?: Snowflake[]; + welcomeChannel?: Snowflake; + muteRole?: Snowflake; + punishmentEnding?: string; +} export class Guild extends BaseModel implements GuildModel { - id: string; - prefix: string; + id!: string; + prefix!: string; autoPublishChannels: string[]; blacklistedChannels: Snowflake[]; welcomeChannel: Snowflake; diff --git a/src/lib/models/Level.ts b/src/lib/models/Level.ts index e1f30f4..b834992 100644 --- a/src/lib/models/Level.ts +++ b/src/lib/models/Level.ts @@ -1,18 +1,25 @@ +import { Snowflake } from 'discord.js'; import { DataTypes, Sequelize } from 'sequelize'; import { BaseModel } from './BaseModel'; export interface LevelModel { - id: string; + id: Snowflake; xp: number; } export interface LevelModelCreationAttributes { - id: string; + id: Snowflake; xp?: number; } export class Level extends BaseModel { - public id: string; + /** + * The user's id. + */ + public id: Snowflake; + /** + * The user's xp. + */ public xp: number; get level(): number { return Level.convertXpToLevel(this.xp); diff --git a/src/lib/models/ModLog.ts b/src/lib/models/ModLog.ts index 6261794..40dc86d 100644 --- a/src/lib/models/ModLog.ts +++ b/src/lib/models/ModLog.ts @@ -38,12 +38,33 @@ export interface ModLogModelCreationAttributes { } export class ModLog extends BaseModel implements ModLogModel { + /** + * The primary key of the modlog entry. + */ id: string; + /** + * The type of punishment. + */ type: ModLogType; + /** + * The user being punished. + */ user: Snowflake; + /** + * The user carrying out the punishment. + */ moderator: Snowflake; + /** + * The reason the user is getting punished + */ reason: string | null; + /** + * The amount of time the user is getting punished for. + */ duration: number | null; + /** + * The guild the user is getting punished in. + */ guild: Snowflake; static initModel(sequelize: Sequelize): void { diff --git a/src/lib/models/Mute.ts b/src/lib/models/Mute.ts index 71a32e3..4208d02 100644 --- a/src/lib/models/Mute.ts +++ b/src/lib/models/Mute.ts @@ -5,15 +5,15 @@ import { BaseModel } from './BaseModel'; export interface MuteModel { id: string; - user: string; - guild: string; + user: Snowflake; + guild: Snowflake; expires: Date; modlog: string; } export interface MuteModelCreationAttributes { id?: string; - user: string; - guild: string; + user: Snowflake; + guild: Snowflake; expires?: Date; modlog: string; } diff --git a/src/lib/models/PunishmentRole.ts b/src/lib/models/PunishmentRole.ts index 927cf28..0b54f31 100644 --- a/src/lib/models/PunishmentRole.ts +++ b/src/lib/models/PunishmentRole.ts @@ -5,15 +5,17 @@ import { BaseModel } from './BaseModel'; export interface PunishmentRoleModel { id: string; - user: string; - guild: string; + user: Snowflake; + role: Snowflake; + guild: Snowflake; expires: Date; modlog: string; } export interface PunishmentRoleModelCreationAttributes { id?: string; - user: string; - guild: string; + user: Snowflake; + role?: Snowflake; + guild: Snowflake; expires?: Date; modlog: string; } @@ -30,6 +32,10 @@ export class PunishmentRole * The user who received a role */ user: Snowflake; + /** + * The role added to the user. + */ + role: Snowflake; /** * The guild they received a role in */ @@ -56,6 +62,10 @@ export class PunishmentRole type: DataTypes.STRING, allowNull: false }, + role: { + type: DataTypes.STRING, + allowNull: false + }, guild: { type: DataTypes.STRING, allowNull: false, -- cgit