mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-07 02:21:27 +03:00
fix: ticket closing
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
const { Modal } = require('@eartharoid/dbf');
|
||||
const ExtendedEmbedBuilder = require('../lib/embed');
|
||||
const Cryptr = require('cryptr');
|
||||
const { encrypt } = new Cryptr(process.env.ENCRYPTION_KEY);
|
||||
|
||||
module.exports = class FeedbackModal extends Modal {
|
||||
constructor(client, options) {
|
||||
super(client, {
|
||||
@@ -19,13 +22,14 @@ module.exports = class FeedbackModal extends Modal {
|
||||
await interaction.deferReply();
|
||||
|
||||
const comment = interaction.fields.getTextInputValue('comment');
|
||||
const rating = parseInt(interaction.fields.getTextInputValue('rating')) || null;
|
||||
let rating = parseInt(interaction.fields.getTextInputValue('rating')) || null; // any integer, or null if NaN
|
||||
rating = Math.min(Math.max(rating, 1), 5); // clamp between 1 and 5 (0 and null become 1, 6 becomes 5)
|
||||
|
||||
const ticket = await client.prisma.ticket.update({
|
||||
data: {
|
||||
feedback: {
|
||||
create: {
|
||||
comment,
|
||||
comment: comment?.length > 0 ? encrypt(comment) : null,
|
||||
guild: { connect: { id: interaction.guild.id } },
|
||||
rating,
|
||||
user: { connect: { id: interaction.user.id } },
|
||||
@@ -36,6 +40,7 @@ module.exports = class FeedbackModal extends Modal {
|
||||
where: { id: interaction.channel.id },
|
||||
});
|
||||
|
||||
|
||||
if (id.next === 'requestClose') await client.tickets.requestClose(interaction, id.reason);
|
||||
else if (id.next === 'acceptClose') await client.tickets.acceptClose(interaction);
|
||||
|
||||
|
Reference in New Issue
Block a user