aboutsummaryrefslogtreecommitdiff
path: root/src/lib/models
diff options
context:
space:
mode:
authorTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-11 22:22:19 -0600
committerTymanWasTaken <32660892+tymanwastaken@users.noreply.github.com>2021-05-11 22:22:19 -0600
commit42d8e605b497c98ed7a4b7e6f31fa1cc6d56e38a (patch)
tree33f7a7dd83960fce281c3f7f028c76baea019f86 /src/lib/models
parent35389d9e41d4a5ddf66fdf64210a334a56281f41 (diff)
downloadtanzanite-42d8e605b497c98ed7a4b7e6f31fa1cc6d56e38a.tar.gz
tanzanite-42d8e605b497c98ed7a4b7e6f31fa1cc6d56e38a.tar.bz2
tanzanite-42d8e605b497c98ed7a4b7e6f31fa1cc6d56e38a.zip
re-organize models
Diffstat (limited to 'src/lib/models')
-rw-r--r--src/lib/models/Ban.ts47
-rw-r--r--src/lib/models/BaseModel.ts6
-rw-r--r--src/lib/models/Guild.ts15
-rw-r--r--src/lib/models/Modlog.ts42
-rw-r--r--src/lib/models/index.ts4
5 files changed, 114 insertions, 0 deletions
diff --git a/src/lib/models/Ban.ts b/src/lib/models/Ban.ts
new file mode 100644
index 0000000..032a48b
--- /dev/null
+++ b/src/lib/models/Ban.ts
@@ -0,0 +1,47 @@
+import { BaseModel } from './BaseModel';
+
+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<BanModel, BanModelCreationAttributes>
+ 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;
+}
diff --git a/src/lib/models/BaseModel.ts b/src/lib/models/BaseModel.ts
new file mode 100644
index 0000000..fdbd706
--- /dev/null
+++ b/src/lib/models/BaseModel.ts
@@ -0,0 +1,6 @@
+import { Model } from 'sequelize';
+
+export abstract class BaseModel<A, B> extends Model<A, B> {
+ public readonly createdAt: Date;
+ public readonly updatedAt: Date;
+}
diff --git a/src/lib/models/Guild.ts b/src/lib/models/Guild.ts
new file mode 100644
index 0000000..3e6c6bf
--- /dev/null
+++ b/src/lib/models/Guild.ts
@@ -0,0 +1,15 @@
+import { Optional } from 'sequelize';
+import { BaseModel } from './BaseModel';
+
+export interface GuildModel {
+ id: string;
+ prefix: string;
+}
+export type GuildModelCreationAttributes = Optional<GuildModel, 'prefix'>;
+
+export class Guild
+ extends BaseModel<GuildModel, GuildModelCreationAttributes>
+ implements GuildModel {
+ id: string;
+ prefix: string;
+}
diff --git a/src/lib/models/Modlog.ts b/src/lib/models/Modlog.ts
new file mode 100644
index 0000000..0a3feba
--- /dev/null
+++ b/src/lib/models/Modlog.ts
@@ -0,0 +1,42 @@
+import { BaseModel } from './BaseModel';
+
+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<ModlogModel, ModlogModelCreationAttributes>
+ implements ModlogModel {
+ id: string;
+ type: ModlogType;
+ user: string;
+ moderator: string;
+ guild: string;
+ reason: string | null;
+ duration: number | null;
+}
diff --git a/src/lib/models/index.ts b/src/lib/models/index.ts
new file mode 100644
index 0000000..ef65415
--- /dev/null
+++ b/src/lib/models/index.ts
@@ -0,0 +1,4 @@
+export * from './BaseModel';
+export * from './Guild';
+export * from './Ban';
+export * from './Modlog';