Skip to content

Commit

Permalink
📤 Send function in TicketBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu11-A committed Jun 13, 2024
1 parent 7aeab1c commit b4e985b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions plugins/tickets/src/class/TicketBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,18 @@ export class TicketBuilder {
return this
}

async send (embeds: EmbedBuilder[]) {
if (this.ticketId === undefined) throw new Error({ element: 'executar essa ação, pois o Id do ticket não foi setado!', interaction: this.interaction }).notPossible().reply()

const ticketData = await ticket.findOne({ where: { id: this.ticketId } })
if (ticketData === null) { await new Error({ element: 'as informações do ticket', interaction: this.interaction }).notFound({ type: 'Database' }).reply(); return }

const channel = await this.interaction.client.channels.fetch(ticketData.channelId).catch(() => null)
if (channel === null && channel === undefined || !channel?.isTextBased()) { await new Error({ element: ticketData.channelId, interaction: this.interaction }).notFound({ type: 'Channel' }).reply(); return }

await channel.send({ embeds })
}

async update () {
if (this.ticketId === undefined) throw new Error({ element: 'executar essa ação, pois o Id do ticket não foi setado!', interaction: this.interaction }).notPossible().reply()

Expand Down

0 comments on commit b4e985b

Please sign in to comment.