mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-17 09:23:07 +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) {
|
if (id.edit) {
|
||||||
await interaction.deferReply({ ephemeral: true });
|
await interaction.deferReply({ ephemeral: true });
|
||||||
|
|
||||||
const { category } = await client.prisma.ticket.findUnique({
|
const { category } = await client.prisma.ticket.findUnique({
|
||||||
select: { category: { select: { customTopic: true } } },
|
select: { category: { select: { customTopic: true } } },
|
||||||
where: { id: interaction.channel.id },
|
where: { id: interaction.channel.id },
|
||||||
});
|
});
|
||||||
let topic;
|
|
||||||
if (category.customTopic) topic = interaction.fields.getTextInputValue(category.customTopic);
|
|
||||||
const select = {
|
const select = {
|
||||||
createdById: true,
|
createdById: true,
|
||||||
guild: {
|
guild: {
|
||||||
@ -50,6 +49,14 @@ module.exports = class QuestionsModal extends Modal {
|
|||||||
select,
|
select,
|
||||||
where: { id: interaction.channel.id },
|
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({
|
const ticket = await client.prisma.ticket.update({
|
||||||
data: {
|
data: {
|
||||||
questionAnswers: {
|
questionAnswers: {
|
||||||
|
Loading…
Reference in New Issue
Block a user