From 763fb7d98c3accbb21adf035a7cf0a83cb9533c9 Mon Sep 17 00:00:00 2001 From: TymanWasTaken <32660892+tymanwastaken@users.noreply.github.com> Date: Tue, 27 Apr 2021 21:06:22 -0600 Subject: legit just copy utilibot v2 code --- src/lib/types/BaseModel.ts | 6 +++ src/lib/types/Models.ts | 102 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 src/lib/types/BaseModel.ts create mode 100644 src/lib/types/Models.ts (limited to 'src/lib/types') diff --git a/src/lib/types/BaseModel.ts b/src/lib/types/BaseModel.ts new file mode 100644 index 0000000..fdbd706 --- /dev/null +++ b/src/lib/types/BaseModel.ts @@ -0,0 +1,6 @@ +import { Model } from 'sequelize'; + +export abstract class BaseModel extends Model { + public readonly createdAt: Date; + public readonly updatedAt: Date; +} diff --git a/src/lib/types/Models.ts b/src/lib/types/Models.ts new file mode 100644 index 0000000..6ea890e --- /dev/null +++ b/src/lib/types/Models.ts @@ -0,0 +1,102 @@ +import { Optional } from 'sequelize'; +import { BaseModel } from './BaseModel'; + +export interface GuildModel { + id: string; + prefix: string; +} +export type GuildModelCreationAttributes = Optional; + +export class Guild + extends BaseModel + implements GuildModel { + id: string; + prefix: string; +} + +export interface BanModel { + id: string; + user: string; + guild: string; + reason: string; + expires: Date; + modlog: string; +} +export interface BanModelCreationAttributes { + id?: string; + user: string; + guild: string; + reason?: string; + expires?: Date; + modlog: string; +} + +export class Ban + extends BaseModel + implements BanModel { + /** + * The ID of this ban (no real use just for a primary key) + */ + id: string; + /** + * The user who is banned + */ + user: string; + /** + * The guild they are banned from + */ + guild: string; + /** + * The reason they are banned (optional) + */ + reason: string | null; + /** + * The date at which this ban expires and should be unbanned (optional) + */ + expires: Date | null; + /** + * The ref to the modlog entry + */ + modlog: string; +} + +export enum ModlogType { + BAN = 'BAN', + TEMPBAN = 'TEMPBAN', + KICK = 'KICK', + MUTE = 'MUTE', + TEMPMUTE = 'TEMPMUTE', + WARN = 'WARN' +} + +export interface ModlogModel { + id: string; + type: ModlogType; + user: string; + moderator: string; + reason: string; + duration: number; + guild: string; +} + +export interface ModlogModelCreationAttributes { + id?: string; + type: ModlogType; + user: string; + moderator: string; + reason?: string; + duration?: number; + guild: string; +} + +export class Modlog + extends BaseModel + implements ModlogModel { + id: string; + type: ModlogType; + user: string; + moderator: string; + guild: string; + reason: string | null; + duration: number | null; +} -- cgit