Error when submitting modal

const {MessageActionRow, Modal, MessageEmbed, TextInputComponent} = require('discord.js')

module.exports = async function(interaction){
if(interaction.isModalSubmit()) return m(interaction)
if(!interaction.isButton()) return
if(interaction.customId !== 'reply') return

const modal = new Modal()
.setCustomId('reply')
.setTitle('Respond to Case')

const content = new TextInputComponent()
.setCustomId('con')
.setLabel('Content')
.setStyle('PARAGRAPH')
.setMinLength(3)
.setMaxLength(2000)

const f = new MessageActionRow().addComponents(content);
modal.addComponents(f)

await interaction.showModal(modal)
}

function m(interaction){
if(interaction.commandId !== 'reply') return

var content = interaction.fields.getTextInputValue('con')
console.log(content)

}
const {MessageActionRow, Modal, MessageEmbed, TextInputComponent} = require('discord.js')

module.exports = async function(interaction){
if(interaction.isModalSubmit()) return m(interaction)
if(!interaction.isButton()) return
if(interaction.customId !== 'reply') return

const modal = new Modal()
.setCustomId('reply')
.setTitle('Respond to Case')

const content = new TextInputComponent()
.setCustomId('con')
.setLabel('Content')
.setStyle('PARAGRAPH')
.setMinLength(3)
.setMaxLength(2000)

const f = new MessageActionRow().addComponents(content);
modal.addComponents(f)

await interaction.showModal(modal)
}

function m(interaction){
if(interaction.commandId !== 'reply') return

var content = interaction.fields.getTextInputValue('con')
console.log(content)

}
I will send error screenshot
10 Replies
duck
duck2y ago
as with all interactions, you need to respond to the modal submit in some way
Jordan
Jordan2y ago
I added interaction.reply('ok") and tried it again but ti still failed
duck
duck2y ago
care to share that code?
Jordan
Jordan2y ago
const {MessageActionRow, Modal, MessageEmbed, TextInputComponent} = require('discord.js')

module.exports = async function(interaction){
if(interaction.isModalSubmit()) return m(interaction)
if(!interaction.isButton()) return
if(interaction.customId !== 'reply') return

const modal = new Modal()
.setCustomId('reply')
.setTitle('Respond to Case')

const content = new TextInputComponent()
.setCustomId('con')
.setLabel('Content')
.setStyle('PARAGRAPH')
.setMinLength(3)
.setMaxLength(2000)

const f = new MessageActionRow().addComponents(content);
modal.addComponents(f)

await interaction.showModal(modal)
}

function m(interaction){
if(interaction.commandId !== 'reply') return

var content = interaction.fields.getTextInputValue('con')
interaction.reply('ok')
}
const {MessageActionRow, Modal, MessageEmbed, TextInputComponent} = require('discord.js')

module.exports = async function(interaction){
if(interaction.isModalSubmit()) return m(interaction)
if(!interaction.isButton()) return
if(interaction.customId !== 'reply') return

const modal = new Modal()
.setCustomId('reply')
.setTitle('Respond to Case')

const content = new TextInputComponent()
.setCustomId('con')
.setLabel('Content')
.setStyle('PARAGRAPH')
.setMinLength(3)
.setMaxLength(2000)

const f = new MessageActionRow().addComponents(content);
modal.addComponents(f)

await interaction.showModal(modal)
}

function m(interaction){
if(interaction.commandId !== 'reply') return

var content = interaction.fields.getTextInputValue('con')
interaction.reply('ok')
}
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Jordan
Jordan2y ago
okay so something like
await awaitModalSubmit()
await awaitModalSubmit()
? will i need to remove the m() function)?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Jordan
Jordan2y ago
Thank you both
duck
duck2y ago
the collectors are one way to receive an interaction, but they're limited by time you won't need to remove your m function, as you could simply call it on the resolved interaction alternatively you can remove it and simply run the code in the same function
Jordan
Jordan2y ago
I will test it and archive this if it works the function was to differentiate the button and modal interaction without switching to another file because they both are for the same overall function
const {MessageActionRow, Modal, MessageEmbed, TextInputComponent} = require('discord.js')

module.exports = async function(interaction){
if(interaction.isModalSubmit()) return m(interaction)
if(!interaction.isButton()) return
if(interaction.customId !== 'reply') return

const modal = new Modal()
.setCustomId('reply')
.setTitle('Respond to Case')

const content = new TextInputComponent()
.setCustomId('con')
.setLabel('Content')
.setStyle('PARAGRAPH')
.setMinLength(3)
.setMaxLength(2000)

const f = new MessageActionRow().addComponents(content);
modal.addComponents(f)

await interaction.showModal(modal)
await interaction.awaitModalSubmit({time: 1000})
}

function m(interaction){
if(interaction.commandId !== 'reply') return

var content = interaction.fields.getTextInputValue('con')
interaction.reply('ok')
}
const {MessageActionRow, Modal, MessageEmbed, TextInputComponent} = require('discord.js')

module.exports = async function(interaction){
if(interaction.isModalSubmit()) return m(interaction)
if(!interaction.isButton()) return
if(interaction.customId !== 'reply') return

const modal = new Modal()
.setCustomId('reply')
.setTitle('Respond to Case')

const content = new TextInputComponent()
.setCustomId('con')
.setLabel('Content')
.setStyle('PARAGRAPH')
.setMinLength(3)
.setMaxLength(2000)

const f = new MessageActionRow().addComponents(content);
modal.addComponents(f)

await interaction.showModal(modal)
await interaction.awaitModalSubmit({time: 1000})
}

function m(interaction){
if(interaction.commandId !== 'reply') return

var content = interaction.fields.getTextInputValue('con')
interaction.reply('ok')
}
This is as far as I got but idk what else i would havbe to do