problems submitting modals

const { ModalBuilder, TextInputBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionsBitField, TextInputStyle } = require("discord.js");
const Fighter = require(`../../schemas/users`);
const mongoose = require('mongoose');

module.exports = {
data: {
name: 'randomOne'
},
async execute(interaction, client) {

const modal = new ModalBuilder()
.setCustomId("registerOne")
.setTitle("Register Yourself");

const textInput = new TextInputBuilder()
.setCustomId("in-game-name")
.setLabel("In-Game Name")
.setPlaceholder("Enter your in-game name")
.setRequired(true)
.setStyle(TextInputStyle.Short);

const one = new ActionRowBuilder().addComponents(textInput);

modal.addComponents(one, two, three);

await interaction.showModal(modal);

interaction.client.on("modalResponse", async (modalInteraction) => {
if (modalInteraction.customId === "registerOne") {
const inGameName = modalInteraction.fields.getTextInputValue("in-game-name");

await interaction.followUp({
content: `Your In-Game Name: ${inGameName}`,
ephemeral: true
});
}
});
},
};
const { ModalBuilder, TextInputBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionsBitField, TextInputStyle } = require("discord.js");
const Fighter = require(`../../schemas/users`);
const mongoose = require('mongoose');

module.exports = {
data: {
name: 'randomOne'
},
async execute(interaction, client) {

const modal = new ModalBuilder()
.setCustomId("registerOne")
.setTitle("Register Yourself");

const textInput = new TextInputBuilder()
.setCustomId("in-game-name")
.setLabel("In-Game Name")
.setPlaceholder("Enter your in-game name")
.setRequired(true)
.setStyle(TextInputStyle.Short);

const one = new ActionRowBuilder().addComponents(textInput);

modal.addComponents(one, two, three);

await interaction.showModal(modal);

interaction.client.on("modalResponse", async (modalInteraction) => {
if (modalInteraction.customId === "registerOne") {
const inGameName = modalInteraction.fields.getTextInputValue("in-game-name");

await interaction.followUp({
content: `Your In-Game Name: ${inGameName}`,
ephemeral: true
});
}
});
},
};
when i fill my details in the modal, it says something went wrong...
6 Replies
Spinel
Spinel16mo ago
<:_:898645159934316565> Interaction#isModalSubmit() Indicates whether this interaction is a ModalSubmitInteraction
Lioness100
Lioness10016mo ago
Or use interaction.awaitModalSubmit(), which does the event listening for you.
Spinel
Spinel16mo ago
<:_:898645159934316565> CommandInteraction#awaitModalSubmit() Collects a single modal submit interaction that passes the filter. The Promise will reject if the time expires.
Resident Of Prey
Resident Of PreyOP16mo ago
is that await necessary? ok i will try
Lioness100
Lioness10016mo ago
Yes
Resident Of Prey
Resident Of PreyOP16mo ago
ok ty
Want results from more Discord servers?
Add your server