mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-05 04:13:08 +02:00
fix: editing question answers in a category with customTopic
set
This commit is contained in:
parent
8971c0ad13
commit
47fc7bde43
@ -27,12 +27,11 @@ module.exports = class QuestionsModal extends Modal {
|
||||
|
||||
if (id.edit) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
const { category } = await client.prisma.ticket.findUnique({
|
||||
select: { category: { select: { customTopic: true } } },
|
||||
where: { id: interaction.channel.id },
|
||||
});
|
||||
let topic;
|
||||
if (category.customTopic) topic = interaction.fields.getTextInputValue(category.customTopic);
|
||||
const select = {
|
||||
createdById: true,
|
||||
guild: {
|
||||
@ -50,6 +49,14 @@ module.exports = class QuestionsModal extends Modal {
|
||||
select,
|
||||
where: { id: interaction.channel.id },
|
||||
});
|
||||
|
||||
let topic;
|
||||
if (category.customTopic) {
|
||||
const customTopicAnswer = original.questionAnswers.find(a => a.question.id === category.customTopic);
|
||||
if (!customTopicAnswer) throw new Error('Custom topic answer not found');
|
||||
topic = interaction.fields.getTextInputValue(String(customTopicAnswer.id));
|
||||
}
|
||||
|
||||
const ticket = await client.prisma.ticket.update({
|
||||
data: {
|
||||
questionAnswers: {
|
||||
@ -121,4 +128,4 @@ module.exports = class QuestionsModal extends Modal {
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user