-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
27 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 15 additions & 7 deletions
22
plugins/tickets/src/discord/components/Template/OpenTicket.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
import { TicketBuilder } from "@/class/TicketBuilder"; | ||
import { Database } from "@/controller/database"; | ||
import { Component } from "@/discord/base"; | ||
import { ButtonInteraction } from "discord.js"; | ||
import { Error } from "@/discord/base/CustomResponse"; | ||
import Template from "@/entity/Template.entry"; | ||
|
||
const template = new Database<Template>({ table: 'Template' }) | ||
|
||
new Component({ | ||
customId: 'Open', | ||
type: 'Button', | ||
cache: 'cached', | ||
async run(interaction) { | ||
const ticket = new TicketBuilder({ interaction: interaction as ButtonInteraction<'cached'> }) | ||
const result = await ticket.setOwner(interaction.user.id).render().create() | ||
if (result === null || result === undefined) return | ||
|
||
// await ticket.delete({ id: result.id }) | ||
}, | ||
if (!interaction.inCachedGuild()) return | ||
await interaction.deferReply({ ephemeral: true }) | ||
|
||
const { user, message } = interaction | ||
const templateData = await template.findOne({ where: { messageId: message.id } }) | ||
if (templateData === null) return await new Error({ element: 'esse template', interaction }).notFound({ type: "Database" }).reply() | ||
|
||
const ticket = new TicketBuilder({ interaction: interaction }) | ||
await ticket.setOwner(user.id).setTemplateId(templateData.id).render().create() | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters