diff --git a/plugins/tickets/src/entity/Guild.entry.ts b/plugins/tickets/src/entity/Guild.entry.ts index f94874f6..9a23184b 100644 --- a/plugins/tickets/src/entity/Guild.entry.ts +++ b/plugins/tickets/src/entity/Guild.entry.ts @@ -1,6 +1,7 @@ import { BaseEntity, Entity, JoinColumn, OneToMany, OneToOne, PrimaryColumn } from "typeorm"; import Ticket from "./Ticket.entry"; import Config from "./Config.entry"; +import Template from "./Template.entry"; @Entity({ name: 'guild_tickets' }) export default class Guild extends BaseEntity { @@ -10,6 +11,9 @@ export default class Guild extends BaseEntity { @OneToMany(() => Ticket, (ticket) => ticket.guild, { cascade: true }) tickets!: Ticket[] + @OneToMany(() => Template, (ticket) => ticket.guild, { cascade: true }) + templates!: Template[] + @OneToOne(() => Config, (config) => config.guild, { cascade: true }) @JoinColumn() configs!: Config diff --git a/plugins/tickets/src/entity/Template.entry.ts b/plugins/tickets/src/entity/Template.entry.ts index 11b9f427..68579fec 100644 --- a/plugins/tickets/src/entity/Template.entry.ts +++ b/plugins/tickets/src/entity/Template.entry.ts @@ -1,5 +1,6 @@ import { APIEmbed } from "discord.js"; -import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from "typeorm"; +import { BaseEntity, Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm"; +import Guild from "./Guild.entry"; interface Properties { [key: string]: boolean | string @@ -27,6 +28,9 @@ export default class Template extends BaseEntity { @PrimaryGeneratedColumn() id!: number + @ManyToOne(() => Guild, (guild) => guild.templates) + guild!: Guild + @Column({ type: 'text' }) messageId!: string @@ -40,7 +44,7 @@ export default class Template extends BaseEntity { }) type!: TypeTemplate - @Column('json', { + @Column('simple-json', { nullable: true, transformer: { to(value: string): string { @@ -53,7 +57,8 @@ export default class Template extends BaseEntity { }) selects!: Select[] - @Column('json', { + @Column('simple-json', { + nullable: true, transformer: { to(value: string): string { return JSON.stringify(value) @@ -65,7 +70,8 @@ export default class Template extends BaseEntity { }) categories!: Category[] - @Column('json', { + @Column('simple-json', { + nullable: true, transformer: { to(value: string): string { return JSON.stringify(value) @@ -77,7 +83,8 @@ export default class Template extends BaseEntity { }) embed!: APIEmbed - @Column('json', { + @Column('simple-json', { + nullable: true, transformer: { to(value: string): string { return JSON.stringify(value)