TypeError: Cannot read properties of undefined (reading 'getTextInputValue')
https://sourceb.in/GVG52tboOv this is my JavaScript file. I want when I send modal it will send value of textinput into console just for test, but I`m having an error: TypeError: Cannot read properties of undefined (reading 'getTextInputValue')
11 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Some interaction types do not have a
.fields
property so interaction.fields
may be undefined. Use type guards so that this only gets checked for modal submit interactions
Also it doesn't need to be awaited because it's not a PromiseWhat should I replace this part with? Thank you for help.
You don't have to replace it, just don't try to use it unless you check whether the interaction is a modal first
so i have to check if the interaction is modal and then it should work?
Yes it will work if the interaction is a modal
i should check it with:
if (interaction.isModalSubmit()) {}
?Yep, that's the correct type guard
I tried:
but it doesn't logs test in console
Then the code isn't running or the interaction isn't a modal
i tried it in my interactionCreate file and now it logs "test" in console
so i think i should do it thru another file