From 34c3ed1b6a034145b4336000cba5ca4b545c4d66 Mon Sep 17 00:00:00 2001 From: Isaac Date: Thu, 9 Feb 2023 21:50:50 +0000 Subject: [PATCH] fix: `/topic` command when there was previously no topic --- src/commands/slash/topic.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/commands/slash/topic.js b/src/commands/slash/topic.js index 07e7617..eed8da8 100644 --- a/src/commands/slash/topic.js +++ b/src/commands/slash/topic.js @@ -57,6 +57,17 @@ module.exports = class TopicSlashCommand extends SlashCommand { const getMessage = client.i18n.getLocale(ticket.guild.locale); + const field = new TextInputBuilder() + .setCustomId('topic') + .setLabel(getMessage('modals.topic.label')) + .setStyle(TextInputStyle.Paragraph) + .setMaxLength(1000) + .setMinLength(5) + .setPlaceholder(getMessage('modals.topic.placeholder')) + .setRequired(true); + + if (ticket.topic) field.setValue(decrypt(ticket.topic)); // why can't discord.js accept null or undefined :( + await interaction.showModal( new ModalBuilder() .setCustomId(JSON.stringify({ @@ -66,17 +77,7 @@ module.exports = class TopicSlashCommand extends SlashCommand { .setTitle(ticket.category.name) .setComponents( new ActionRowBuilder() - .setComponents( - new TextInputBuilder() - .setCustomId('topic') - .setLabel(getMessage('modals.topic.label')) - .setStyle(TextInputStyle.Paragraph) - .setMaxLength(1000) - .setMinLength(5) - .setPlaceholder(getMessage('modals.topic.placeholder')) - .setRequired(true) - .setValue(ticket.topic ? decrypt(ticket.topic) : ''), - ), + .setComponents(field), ), ); }