Anyone knows why my interaction for my modal isnt working?

const { CommandInteraction, ApplicationCommandAutoComplete , InteractionType, Events} = require("discord.js");

module.exports = {
name: "interactionCreate",

async execute(interaction, client) {
if(interaction.type == InteractionType.ApplicationCommandAutocomplete){
const {commands} = client;
const {commandName} = interaction;
const command = commands.get(commandName);
if (!command) return;

try {
await command.autocomplete(interaction, client)
} catch (error){
console.error(error);
}
}
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isModalSubmit()) return;
if (interaction.customId === 'customDinoModal') {
await interaction.reply({ content: 'Nome do dino enviado a database.' });
}
});

},
};
const { CommandInteraction, ApplicationCommandAutoComplete , InteractionType, Events} = require("discord.js");

module.exports = {
name: "interactionCreate",

async execute(interaction, client) {
if(interaction.type == InteractionType.ApplicationCommandAutocomplete){
const {commands} = client;
const {commandName} = interaction;
const command = commands.get(commandName);
if (!command) return;

try {
await command.autocomplete(interaction, client)
} catch (error){
console.error(error);
}
}
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isModalSubmit()) return;
if (interaction.customId === 'customDinoModal') {
await interaction.reply({ content: 'Nome do dino enviado a database.' });
}
});

},
};
3 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Ashura
AshuraOP2y ago
const customDinonameInput = new TextInputBuilder()
.setMinLength(1)
.setMaxLength(50)
.setCustomId('customDinonameInput')
.setLabel("Qual o nome do dino que sera breedado?")
.setStyle(TextInputStyle.Short)


client.on(Events.InteractionCreate, interaction => {
if (!interaction.isModalSubmit()) return;
if (dinoname != choices) {
const modal = new ModalBuilder()
.setCustomId('customDinoModal')
.setTitle('Sunflower-LineCreator')
.addComponents(customDinonameInput);
interaction.showModal(modal);
const customDinoName = interaction.fields.getTextInputValue('customDinonameInput');
dinoname = customDinoName
}
});
const customDinonameInput = new TextInputBuilder()
.setMinLength(1)
.setMaxLength(50)
.setCustomId('customDinonameInput')
.setLabel("Qual o nome do dino que sera breedado?")
.setStyle(TextInputStyle.Short)


client.on(Events.InteractionCreate, interaction => {
if (!interaction.isModalSubmit()) return;
if (dinoname != choices) {
const modal = new ModalBuilder()
.setCustomId('customDinoModal')
.setTitle('Sunflower-LineCreator')
.addComponents(customDinonameInput);
interaction.showModal(modal);
const customDinoName = interaction.fields.getTextInputValue('customDinonameInput');
dinoname = customDinoName
}
});
Squid
Squid2y ago
You should not have nested event listeners You should use collectors if you want to collect a new interaction within a listener
Want results from more Discord servers?
Add your server