mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-22 15:53:08 +02:00
fix: only send value if not empty (closes #458)
This commit is contained in:
parent
e695aa2147
commit
bcd02b1dea
@ -36,6 +36,15 @@ module.exports = class EditButton extends Button {
|
|||||||
const getMessage = client.i18n.getLocale(ticket.guild.locale);
|
const getMessage = client.i18n.getLocale(ticket.guild.locale);
|
||||||
|
|
||||||
if (ticket.questionAnswers.length === 0) {
|
if (ticket.questionAnswers.length === 0) {
|
||||||
|
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(cryptr.decrypt(ticket.topic));
|
||||||
await interaction.showModal(
|
await interaction.showModal(
|
||||||
new ModalBuilder()
|
new ModalBuilder()
|
||||||
.setCustomId(JSON.stringify({
|
.setCustomId(JSON.stringify({
|
||||||
@ -45,17 +54,7 @@ module.exports = class EditButton extends Button {
|
|||||||
.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 ? cryptr.decrypt(ticket.topic) : ''),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -71,18 +70,17 @@ module.exports = class EditButton extends Button {
|
|||||||
.filter(a => a.question.type === 'TEXT') // TODO: remove this when modals support select menus
|
.filter(a => a.question.type === 'TEXT') // TODO: remove this when modals support select menus
|
||||||
.map(a => {
|
.map(a => {
|
||||||
if (a.question.type === 'TEXT') {
|
if (a.question.type === 'TEXT') {
|
||||||
return new ActionRowBuilder()
|
const field = new TextInputBuilder()
|
||||||
.setComponents(
|
.setCustomId(String(a.id))
|
||||||
new TextInputBuilder()
|
.setLabel(a.question.label)
|
||||||
.setCustomId(String(a.id))
|
.setStyle(a.question.style)
|
||||||
.setLabel(a.question.label)
|
.setMaxLength(Math.min(a.question.maxLength, 1000))
|
||||||
.setStyle(a.question.style)
|
.setMinLength(a.question.minLength)
|
||||||
.setMaxLength(Math.min(a.question.maxLength, 1000))
|
.setPlaceholder(a.question.placeholder)
|
||||||
.setMinLength(a.question.minLength)
|
.setRequired(a.question.required);
|
||||||
.setPlaceholder(a.question.placeholder)
|
if (a.value) field.setValue(cryptr.decrypt(a.value));
|
||||||
.setRequired(a.question.required)
|
else if (a.question.value) field.setValue(a.question.value);
|
||||||
.setValue(a.value ? cryptr.decrypt(a.value) : a.question.value),
|
return new ActionRowBuilder().setComponents(field);
|
||||||
);
|
|
||||||
} else if (a.question.type === 'MENU') {
|
} else if (a.question.type === 'MENU') {
|
||||||
return new ActionRowBuilder()
|
return new ActionRowBuilder()
|
||||||
.setComponents(
|
.setComponents(
|
||||||
|
@ -285,18 +285,16 @@ module.exports = class TicketManager {
|
|||||||
.filter(q => q.type === 'TEXT') // TODO: remove this when modals support select menus
|
.filter(q => q.type === 'TEXT') // TODO: remove this when modals support select menus
|
||||||
.map(q => {
|
.map(q => {
|
||||||
if (q.type === 'TEXT') {
|
if (q.type === 'TEXT') {
|
||||||
return new ActionRowBuilder()
|
const field = new TextInputBuilder()
|
||||||
.setComponents(
|
.setCustomId(q.id)
|
||||||
new TextInputBuilder()
|
.setLabel(q.label)
|
||||||
.setCustomId(q.id)
|
.setStyle(q.style)
|
||||||
.setLabel(q.label)
|
.setMaxLength(Math.min(q.maxLength, 1000))
|
||||||
.setStyle(q.style)
|
.setMinLength(q.minLength)
|
||||||
.setMaxLength(Math.min(q.maxLength, 1000))
|
.setPlaceholder(q.placeholder)
|
||||||
.setMinLength(q.minLength)
|
.setRequired(q.required);
|
||||||
.setPlaceholder(q.placeholder)
|
if (q.value) field.setValue(q.value);
|
||||||
.setRequired(q.required)
|
return new ActionRowBuilder().setComponents(field);
|
||||||
.setValue(q.value),
|
|
||||||
);
|
|
||||||
} else if (q.type === 'MENU') {
|
} else if (q.type === 'MENU') {
|
||||||
return new ActionRowBuilder()
|
return new ActionRowBuilder()
|
||||||
.setComponents(
|
.setComponents(
|
||||||
|
Loading…
Reference in New Issue
Block a user