#Modal Wont show in v14

38 messages · Page 1 of 1 (latest)

gray kayak
#

This is the code im using:

client.on('interactionCreate', async (interaction) => {
    if (interaction.isButton()) {

        if (interaction.customId.startsWith("thread")) {
            const modal = new ModalBuilder()
                .setCustomId('modalId')
                .setTitle('McSkripters Helper');
            const name = new TextInputBuilder()
                .setCustomId('DisName')
                .setLabel("[REQUIRED] ENTER DISCORD NAME HERE")
                .setStyle(TextInputStyle.Short);
            const issue = new TextInputBuilder()
                .setCustomId('DisIssue')
                .setLabel("[REQUIRED] DISCRIBE YOUR ISSUE")
                .setStyle(TextInputStyle.Short);
            const code = new TextInputBuilder()
                .setCustomId('DisCode')
                .setLabel("[OPTIONAL] ADD YOUR CODE")
                .setStyle(TextInputStyle.Paragraph);
            const error = new TextInputBuilder()
                .setCustomId('DisError')
                .setLabel("[OPTIONAL] POST YOUR ERRORS")
                .setStyle(TextInputStyle.Short);
            const firstActionRow = new ActionRowBuilder().addComponents(name);
            const secondActionRow = new ActionRowBuilder().addComponents(issue);
            const thirdActionRow = new ActionRowBuilder().addComponents(code);
            const fourthActionRow = new ActionRowBuilder().addComponents(error);
            modal.addComponents(firstActionRow, secondActionRow, thirdActionRow, fourthActionRow);
            await interaction.showModal(modal);
        }
    }
});``` Error here:
```js
at async ButtonInteraction.showModal (/home/opc/SkParser/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:246:5)
1|index  |     at async Client.<anonymous> (/home/opc/SkParser/index.js:170:13) {
1|index  |   rawError: { message: 'Unknown interaction', code: 10062 }```
eager peakBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

gray kayak
#
discord.js@14.4.0
v16.17.0```
#

Its saying this line in giving a error. I just have no idea whats wrong with it?

await interaction.showModal(modal);```
orchid flame
#

Well it's pretty obvious, but your not replying within 3 seconds

gray kayak
#

I just a little confused. I was on v13 today with the same exact code, and didnt have this issue at all. Once i updated to v14, it did this. How exactly could i fix this? I have tried just about all i can do. Im running out of ideas now

orchid flame
#

Are you sure your on v14 btw?

gray kayak
#

100% sure yeah

orchid flame
#

interaction.isButton isn't a thing on v14

eager peakBOT
sick igloo
#

sure it is

gray kayak
#

Ahh that could be the issue. Im still pretty new to v14. Thank you guys! 🙂

orchid flame
# sick igloo sure it is

I swear they removed it, the guide said to use interaction.type === some enum, but if they reverted

sick igloo
orchid flame
#

Interesting

gray kayak
#

So would it be something like this then? 🤔

client.on('interactionCreate', async (interaction) => {
    if (interaction.type === Button()) {

        if (interaction.customId.startsWith("thread")) {
            const modal = new ModalBuilder()
                .setCustomId('modalId')
                .setTitle('McSkripters Helper');
            const name = new TextInputBuilder()
                .setCustomId('DisName')
                .setLabel("[REQUIRED] ENTER DISCORD NAME HERE")
                .setStyle(TextInputStyle.Short);
            const issue = new TextInputBuilder()
                .setCustomId('DisIssue')
                .setLabel("[REQUIRED] DISCRIBE YOUR ISSUE")
                .setStyle(TextInputStyle.Short);
            const code = new TextInputBuilder()
                .setCustomId('DisCode')
                .setLabel("[OPTIONAL] ADD YOUR CODE")
                .setStyle(TextInputStyle.Paragraph);
            const error = new TextInputBuilder()
                .setCustomId('DisError')
                .setLabel("[OPTIONAL] POST YOUR ERRORS")
                .setStyle(TextInputStyle.Short);
            const firstActionRow = new ActionRowBuilder().addComponents(name);
            const secondActionRow = new ActionRowBuilder().addComponents(issue);
            const thirdActionRow = new ActionRowBuilder().addComponents(code);
            const fourthActionRow = new ActionRowBuilder().addComponents(error);
            modal.addComponents(firstActionRow, secondActionRow, thirdActionRow, fourthActionRow);
            interaction.showModal(modal);
        }
    }
});```
orchid flame
#

no no, I was wrong revert it

gray kayak
#

Ok

#

Im getting two different answers here tho xD My brain is about to explode in a few minutes lol

sick igloo
#

just revert back to how it was before

gray kayak
#

I did, and its back to the code that isnt working. I just have no idea why

sick igloo
#

do you have a good internet connection ._.

gray kayak
#

Yeah. How come?

sick igloo
#

Error usually happens when you are replying too late

gray kayak
#

Very weird. So by the look of the code, it looks all correct then?

versed mesa
#

first check if you are running two instances of your bot with old code or if you’re running old code without saving it, happened to me couple times and then you can deferReply and then show the modal

orchid flame
#

Objection

#

You can't deferReply and show modal

#

Both are response types

#

So you can't reply then reply again

#

I tried it

#

Didn't work

versed mesa
#

also interaction.type === Button() is not a thing

orchid flame
#

Is the OP