fix: /topic command when there was previously no topic

This commit is contained in:
Isaac 2023-02-09 21:50:50 +00:00
parent c5f092ce2f
commit 34c3ed1b6a
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33

View File

@ -57,6 +57,17 @@ module.exports = class TopicSlashCommand extends SlashCommand {
const getMessage = client.i18n.getLocale(ticket.guild.locale); 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( await interaction.showModal(
new ModalBuilder() new ModalBuilder()
.setCustomId(JSON.stringify({ .setCustomId(JSON.stringify({
@ -66,17 +77,7 @@ module.exports = class TopicSlashCommand extends SlashCommand {
.setTitle(ticket.category.name) .setTitle(ticket.category.name)
.setComponents( .setComponents(
new ActionRowBuilder() new ActionRowBuilder()
.setComponents( .setComponents(field),
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) : ''),
),
), ),
); );
} }