Skip to content

Commit

Permalink
🆕 Add setData and addEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu11-A committed Jun 6, 2024
1 parent 3b7eff8 commit 317c428
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
18 changes: 11 additions & 7 deletions plugins/tickets/src/class/TicketBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export class TicketBuilder {
team: [],
users: [],
messages: [],
history: []
history: [],
events: []
}
}

Expand All @@ -46,12 +47,15 @@ export class TicketBuilder {
setClosed(isClosed: boolean) { this.options.closed = isClosed ?? false; return this }
setVoice(voice: Voice) { this.options.voice = voice; return this }
setCategory (category: TicketCategories) { this.options.category = category; return this }
setClaim (message: Message) { this.options.claim = message; return this }
setClaim (message: TicketMessage) { this.options.claim = message; return this }

addUsers (user: User) { this.options.users.push(user); return this }
addTeam (user: User) { this.options.team.push(user); return this }
addMessage (message: Message) { this.options.messages.push(message); return this }
setData(data: Ticket) { this.options = Object.assign(this.options, data); return this }

addTeam (user: UserTicket) { this.options.team.push(user); return this }
addUsers (user: UserTicket) { this.options.users.push(user); return this }
addEvent (event: Event) { this.options.events.push(event); return this }
addHistory (content: History) { this.options.history.push(content); return this }
addMessage (message: TicketMessage) { this.options.messages.push(message); return this }

private permissions (): OverwriteResolvable[] {
const { guild } = this.interaction
Expand Down Expand Up @@ -109,8 +113,8 @@ export class TicketBuilder {
footer: { text: `Equipe ${guild?.name} | ${new Date().toLocaleString('pt-BR', { timeZone: 'America/Sao_Paulo' })}`, iconURL: (guild?.iconURL({ size: 64 }) ?? undefined) }
})

if (title !== undefined) embed.addFields({ name: '📃 Motivo:', value: codeBlock(title) })
if (description !== undefined) embed.addFields({ name: '📭 Descrição:', value: codeBlock(description) })
if (typeof title === 'string') embed.addFields({ name: '📃 Motivo:', value: codeBlock(title) })
if (typeof description === 'string') embed.addFields({ name: '📭 Descrição:', value: codeBlock(description) })

const buttons: ButtonBuilder[] = []
buttons.push(
Expand Down
20 changes: 20 additions & 0 deletions plugins/tickets/src/entity/Ticket.entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ export interface History {
deleted: boolean
}

export interface Event {
user: {
id: string
name: string
}
message: string
date: Date
}

export interface Message {
channelId: string
messageId: string
Expand Down Expand Up @@ -51,6 +60,7 @@ export interface TicketType {
users: User[]
history: History[]
messages: Message[]
events: Event[]
}

@Entity({ name: 'tickets' })
Expand Down Expand Up @@ -133,6 +143,16 @@ export default class Ticket extends BaseEntity {
})
messages!: Message[]

@Column({
type: 'simple-json',
nullable: true,
transformer: {
to(value: string): string { return JSON.stringify(value) },
from(value: string): Event[] { return JSON.parse(value) },
}
})
events!: Event[]

@Column({
type: 'simple-json',
nullable: true,
Expand Down

0 comments on commit 317c428

Please sign in to comment.