ModalSubmit error

Hey there! I'm trying to get my modals working one for eval and one for newchangelog, the eval one works as intended but the newchangelog one doesn't, when I enter the message for the changelog, it says something went wrong, try again. I checked console to have an error saying "TypeError: Cannot read properties of undefined (reading 'getString')" I'm trying to get the string from the command itself into interactionCreate.js, it is possible?
3 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
vance_
vance_2y ago
Here's my code that I manage the newchangelog.js command with
if (interaction.isModalSubmit()) {
if (interaction.customId === 'modal_xd') {
try {
const changelogValue = interaction.fields.getTextInputValue("changelog");
const changelog = require('../database/changelogSchema');

const CP = await changelog.findOne({
ident: "counter",
});

const date2 = new Date().toLocaleDateString();

if (CP)
await CP.update({
changelog: `${changelogValue}`,
date: `${date2}`,
type: interaction.options.getString("type")
})

client.warn("[Manager] Updated Quadro's changelog.")

interaction.reply({ embeds: [
new MessageEmbed()
.setTitle("Updated changelog!")
.addFields(
{
name: "Message",
value: changelogValue
},
{
name: "Type",
value: interaction.options.getString("type")
},
{
name: "Date",
value: date2
}
)
.setColor(client.config.embedColor)
], ephemeral: true
})
} catch (error) {
client.error(error)
}
}
}
if (interaction.isModalSubmit()) {
if (interaction.customId === 'modal_xd') {
try {
const changelogValue = interaction.fields.getTextInputValue("changelog");
const changelog = require('../database/changelogSchema');

const CP = await changelog.findOne({
ident: "counter",
});

const date2 = new Date().toLocaleDateString();

if (CP)
await CP.update({
changelog: `${changelogValue}`,
date: `${date2}`,
type: interaction.options.getString("type")
})

client.warn("[Manager] Updated Quadro's changelog.")

interaction.reply({ embeds: [
new MessageEmbed()
.setTitle("Updated changelog!")
.addFields(
{
name: "Message",
value: changelogValue
},
{
name: "Type",
value: interaction.options.getString("type")
},
{
name: "Date",
value: date2
}
)
.setColor(client.config.embedColor)
], ephemeral: true
})
} catch (error) {
client.error(error)
}
}
}
monbrey
monbrey2y ago
Nope, interaction here is the modal, not the slash command You might be better off using awaitModalSubmit in the slash commands scope of execution