Bladeren bron

Add DB entities for violation data

ghorsington 4 jaren geleden
bovenliggende
commit
a20c6b4757
3 gewijzigde bestanden met toevoegingen van 50 en 1 verwijderingen
  1. 8 1
      shared/src/db/entities.ts
  2. 10 0
      shared/src/db/entity/GuildViolationSettings.ts
  3. 32 0
      shared/src/db/entity/Violation.ts

+ 8 - 1
shared/src/db/entities.ts

@@ -15,6 +15,8 @@ import { ContestVote } from "./entity/ContestVote";
 import { FileOnlyChannel } from "./entity/FileOnlyChannel";
 import { RandomMessageReaction } from "./entity/RandomMesssageReaction";
 import { GuildGreeting } from "./entity/GuildGreeting";
+import { Violation, Mute, Kick, Ban } from "./entity/Violation";
+import { GuildViolationSettings } from "./entity/GuildViolationSettings";
 
 export const DB_ENTITIES = [
     AggroNewsItem,
@@ -36,5 +38,10 @@ export const DB_ENTITIES = [
     ContestVote,
     FileOnlyChannel,
     RandomMessageReaction,
-    GuildGreeting
+    GuildGreeting,
+    Violation,
+    Mute,
+    Kick,
+    Ban,
+    GuildViolationSettings,
 ];

+ 10 - 0
shared/src/db/entity/GuildViolationSettings.ts

@@ -0,0 +1,10 @@
+import { Entity, PrimaryColumn, Column } from "typeorm";
+
+@Entity()
+export class GuildViolationSettings {
+    @PrimaryColumn()
+    guildId: string;
+
+    @Column({ nullable: true })
+    muteChannelId?: string;
+}

+ 32 - 0
shared/src/db/entity/Violation.ts

@@ -0,0 +1,32 @@
+import { Entity, Column, PrimaryGeneratedColumn, ChildEntity, TableInheritance } from "typeorm";
+
+@Entity()
+@TableInheritance({column: { type: "varchar", name: "type" }})
+export abstract class Violation {
+    @PrimaryGeneratedColumn()
+    id: number;
+
+    @Column()
+    guildId: string;
+
+    @Column()
+    userId: string;
+
+    @Column({ type: "text", nullable: true })
+    reason?: string;
+}
+
+@ChildEntity()
+export class Mute extends Violation {
+    @Column()
+    endsAt: Date;
+}
+
+@ChildEntity()
+export class Ban extends Violation {
+    @Column()
+    endsAt: Date;
+}
+
+@ChildEntity()
+export class Kick extends Violation {}