#Can't send modals ( An error occured )

36 messages · Page 1 of 1 (latest)

wispy rock
#

Hi, i'm getting an error while sending modals
code: js if(interaction.type === InteractionType.ModalSubmit) { console.log(interaction) if((interaction as ModalSubmitInteraction).customId === "modal-contact-admin") { console.log((interaction as ModalSubmitInteraction).fields.getField("modal-input-admin").value) }

Error : An error occured | directly on the modal

I receive the interaction correctly, seems he cant handle it.

final mapleBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by OP
wispy rock
rocky agate
#

and where do you reply to the interaction

wispy rock
rocky agate
#

show that code then

wispy rock
#

You got it, it's on the post

#
 if(interaction.type === InteractionType.ModalSubmit) {
            console.log(interaction)
           if((interaction as ModalSubmitInteraction).customId === "modal-contact-admin") {
            console.log((interaction as ModalSubmitInteraction).fields.getField("modal-input-admin").value)
           }```
novel lichen
#

there's no reply

wispy rock
#

As there's no reply, if I just log values, it won't respond ?

rocky agate
#

yes

wispy rock
#

Added this js (interaction as ModalSubmitInteraction).reply("ok")

#

Seems to not working

novel lichen
#

you don't need to type each interaction as ModalSubmitInteraction if you check for it in an if statement

#

and "not working" in what way

wispy rock
echo elbowBOT
novel lichen
#

its better if you use the typeguard

wispy rock
#

I got the same error I sent

novel lichen
#

what about in your console

wispy rock
#

if I log the interaction it's ok

#

And there's not catching of errors after

#

Only on UI discord

#

I was handling my modals and as i have this error, i thought it was cuz of my handler but no. Even if i just handle it in interactionCreate, does not work

#

Found the issue

#

I won't say to you cuz i'm embarassed

novel lichen
#

its okay, we all make silly mistakes

#

what was it?

wispy rock
#

I hope it's cuz i'm tired, customId was different

novel lichen
#

dont be embarrassed, its fine

#

im glad you found the issue

wispy rock
#

So, my handler was good tho

wispy rock
#

it's sad lol. Thanks anyway for your help !