Skip to content

Commit

Permalink
🧩 Add function for Delete in Caim
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu11-A committed Jun 14, 2024
1 parent 03aaa78 commit 153bb10
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions plugins/tickets/src/discord/components/Claim/ButtonDel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { TicketBuilder } from "@/class/TicketBuilder.js";
import { Component } from "@/discord/base/Components.js";
import { YouSure } from "@/discord/base/CustomIntetaction.js";
import { Error } from "@/discord/base/CustomResponse.js";
import { claimDB } from "@/functions/database.js";
import { EmbedBuilder } from "discord.js";

new Component({
customId: 'Delete',
type: 'Button',
async run(interaction) {
if (!interaction.inCachedGuild()) return
await interaction.deferReply({ ephemeral: true })
const { message } = interaction
const claimData = await claimDB.findOne({ where: { messageId: message.id }, relations: { ticket: true } })
if (claimData === null) throw await new Error({ element: 'este claim', interaction }).notFound({ type: "Database" }).reply()

const builder = new TicketBuilder({ interaction })
const isDeletable = await new YouSure({ interaction, title: 'Tem certeza que desseja deletar este ticket?' }).question()

if (isDeletable) await builder.setTicket(claimData.ticket.channelId).delete()
},
})

0 comments on commit 153bb10

Please sign in to comment.