Modal Validation Error

const { InteractionHandler, InteractionHandlerTypes } = require('@sapphire/framework')
const { ModalBuilder, TextInputStyle, TextInputBuilder, ActionRowBuilder } = require('discord.js')

module.exports = class extends InteractionHandler {
constructor (ctx) {
super(ctx,
{
interactionHandlerType: InteractionHandlerTypes.SelectMenu
}
)
}

async parse (interaction) {
if (interaction.customId !== 'department' && interaction.customId !== 'staff') return this.none()

return this.some()
}

async run (interaction, result) {
try {
const selected = interaction.values[0]
const modal = new ModalBuilder()
modal.setCustomId(`ticketSubmit_${selected}`)
if (selected === 'inquiry') {
const textInput = new TextInputBuilder()
textInput.setCustomId('inputOne')
textInput.setLabel('What is your question?')
textInput.setStyle(TextInputStyle.Paragraph)

const actionRow = new ActionRowBuilder().addComponents(textInput)
modal.addComponents(actionRow)
} else if (selected === 'report') {
const reportWho = new TextInputBuilder()
reportWho.setCustomId('inputOne')
reportWho.setLabel('Who are you reporting')
reportWho.setStyle(TextInputStyle.Short)

const textInput = new TextInputBuilder()
textInput.setCustomId('inputTwo')
textInput.setLabel('Why are you reporting this individual?')
textInput.setStyle(TextInputStyle.Paragraph)

const actionRow = new ActionRowBuilder().addComponents(reportWho)
const secondActionRow = new ActionRowBuilder().addComponents(textInput)
modal.addComponents(actionRow, secondActionRow)
}

await interaction.showModal(modal)
} catch (err) {
console.error(err)
}
}
}
const { InteractionHandler, InteractionHandlerTypes } = require('@sapphire/framework')
const { ModalBuilder, TextInputStyle, TextInputBuilder, ActionRowBuilder } = require('discord.js')

module.exports = class extends InteractionHandler {
constructor (ctx) {
super(ctx,
{
interactionHandlerType: InteractionHandlerTypes.SelectMenu
}
)
}

async parse (interaction) {
if (interaction.customId !== 'department' && interaction.customId !== 'staff') return this.none()

return this.some()
}

async run (interaction, result) {
try {
const selected = interaction.values[0]
const modal = new ModalBuilder()
modal.setCustomId(`ticketSubmit_${selected}`)
if (selected === 'inquiry') {
const textInput = new TextInputBuilder()
textInput.setCustomId('inputOne')
textInput.setLabel('What is your question?')
textInput.setStyle(TextInputStyle.Paragraph)

const actionRow = new ActionRowBuilder().addComponents(textInput)
modal.addComponents(actionRow)
} else if (selected === 'report') {
const reportWho = new TextInputBuilder()
reportWho.setCustomId('inputOne')
reportWho.setLabel('Who are you reporting')
reportWho.setStyle(TextInputStyle.Short)

const textInput = new TextInputBuilder()
textInput.setCustomId('inputTwo')
textInput.setLabel('Why are you reporting this individual?')
textInput.setStyle(TextInputStyle.Paragraph)

const actionRow = new ActionRowBuilder().addComponents(reportWho)
const secondActionRow = new ActionRowBuilder().addComponents(textInput)
modal.addComponents(actionRow, secondActionRow)
}

await interaction.showModal(modal)
} catch (err) {
console.error(err)
}
}
}
https://i.imgur.com/GAhgd7l.png
Imgur
Solution:
FYI, you can chain builder functions. For example, you can turn: ```ts const textInput = new TextInputBuilder() textInput.setCustomId('inputOne')...
Jump to solution
5 Replies
Lioness100
Lioness1002y ago
@.theedeer Your modal needs a title. You can set it via modal.setTitle('Ticket Submission Form').
Solution
Lioness100
Lioness1002y ago
FYI, you can chain builder functions. For example, you can turn:
const textInput = new TextInputBuilder()
textInput.setCustomId('inputOne')
textInput.setLabel('What is your question?')
textInput.setStyle(TextInputStyle.Paragraph)
const textInput = new TextInputBuilder()
textInput.setCustomId('inputOne')
textInput.setLabel('What is your question?')
textInput.setStyle(TextInputStyle.Paragraph)
into
const textInput = new TextInputBuilder()
.setCustomId('inputOne')
.setLabel('What is your question?')
.setStyle(TextInputStyle.Paragraph)
const textInput = new TextInputBuilder()
.setCustomId('inputOne')
.setLabel('What is your question?')
.setStyle(TextInputStyle.Paragraph)
Lioness100
Lioness1002y ago
Nice try favvy wavvy but that wasn't the solution message MunchlaxMunch
Favna
Favna2y ago
I thought it was one and the same message. Oh well.
Lioness100
Lioness1002y ago
How dare you
Want results from more Discord servers?
Add your server