mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-06 02:01:26 +03:00
more on closing and feedback (WIP)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const { Modal } = require('@eartharoid/dbf');
|
||||
|
||||
const ExtendedEmbedBuilder = require('../lib/embed');
|
||||
module.exports = class FeedbackModal extends Modal {
|
||||
constructor(client, options) {
|
||||
super(client, {
|
||||
@@ -8,24 +8,52 @@ module.exports = class FeedbackModal extends Modal {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} id
|
||||
* @param {import("discord.js").ModalSubmitInteraction} interaction
|
||||
*/
|
||||
async run(id, interaction) {
|
||||
/** @type {import("client")} */
|
||||
const client = this.client;
|
||||
|
||||
await interaction.deferReply();
|
||||
await client.prisma.ticket.update({
|
||||
|
||||
const comment = interaction.fields.getTextInputValue('comment');
|
||||
const rating = parseInt(interaction.fields.getTextInputValue('rating')) || null;
|
||||
|
||||
const ticket = await client.prisma.ticket.update({
|
||||
data: {
|
||||
feedback: {
|
||||
create: {
|
||||
comment: interaction.fields.getTextInputValue('comment'),
|
||||
comment,
|
||||
guild: { connect: { id: interaction.guild.id } },
|
||||
rating: parseInt(interaction.fields.getTextInputValue('rating')) || null,
|
||||
rating,
|
||||
user: { connect: { id: interaction.user.id } },
|
||||
},
|
||||
},
|
||||
},
|
||||
include: { guild: true },
|
||||
where: { id: interaction.channel.id },
|
||||
});
|
||||
await client.tickets.requestClose(interaction, id.reason);
|
||||
|
||||
if (id.next === 'requestClose') await client.tickets.requestClose(interaction, id.reason);
|
||||
else if (id.next === 'acceptClose') await client.tickets.acceptClose(interaction);
|
||||
|
||||
const getMessage = client.i18n.getLocale(ticket.guild.locale);
|
||||
|
||||
// `followUp` must go after `reply`/`editReply` (the above)
|
||||
if (comment?.length > 0 && rating !== null) {
|
||||
await interaction.followUp({
|
||||
embeds: [
|
||||
new ExtendedEmbedBuilder({
|
||||
iconURL: interaction.guild.iconURL(),
|
||||
text: ticket.guild.footer,
|
||||
})
|
||||
.setColor(ticket.guild.primaryColour)
|
||||
.setDescription(getMessage('ticket.feedback')),
|
||||
],
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user