Always read a modal InputTextValue but when it doesn't exist it makes a null value of it.

Does anyone know how to always read a modal InputTextValue but when it doesn't exist it makes a null value of it?
const vraag1 = interaction.fields.getTextInputValue('vraag1' || null);
const vraag1 = interaction.fields.getTextInputValue('vraag1') || null;
const vraag1 = interaction.fields.getTextInputValue('vraag1' || null);
const vraag1 = interaction.fields.getTextInputValue('vraag1') || null;
Here is my code with 2 different ways but they all get error with the following:
Connect. ERROR | (Uncaught Exception) TypeError [ModalSubmitInteractionFieldNotFound]: Required field with custom id "vraag1" not found.
at ModalSubmitFields.getField (/home/container/node_modules/discord.js/src/structures/ModalSubmitFields.js:36:23)
at ModalSubmitFields.getTextInputValue (/home/container/node_modules/discord.js/src/structures/ModalSubmitFields.js:51:17)
at Object.execute (/home/container/events/ticket-system/interactionTicketEmbed.js:238:38)
at Client.<anonymous> (/home/container/index.js:74:50)
at Client.emit (node:events:525:35)
at InteractionCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
at Object.module.exports [as INTERACTION_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31) {
code: 'ModalSubmitInteractionFieldNotFound'
Connect. ERROR | (Uncaught Exception) TypeError [ModalSubmitInteractionFieldNotFound]: Required field with custom id "vraag1" not found.
at ModalSubmitFields.getField (/home/container/node_modules/discord.js/src/structures/ModalSubmitFields.js:36:23)
at ModalSubmitFields.getTextInputValue (/home/container/node_modules/discord.js/src/structures/ModalSubmitFields.js:51:17)
at Object.execute (/home/container/events/ticket-system/interactionTicketEmbed.js:238:38)
at Client.<anonymous> (/home/container/index.js:74:50)
at Client.emit (node:events:525:35)
at InteractionCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
at Object.module.exports [as INTERACTION_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31) {
code: 'ModalSubmitInteractionFieldNotFound'
7 Replies
d.js toolkit
d.js toolkit4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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!
monbrey
monbrey4mo ago
Why are you trying to get a field that isnt even in the modal
Gerben
Gerben4mo ago
For futher proving. I want to make it so that when it exist it can be used en when it doesn't exist is gives a null value.
monbrey
monbrey4mo ago
Thats not how modals work, you should know what fields it has You could catch the error I suppose, and set null there
Gerben
Gerben4mo ago
How sould I do that with my code?
axiprime2.0
axiprime2.04mo ago
try {} catch {}
ahmood
ahmood4mo ago
you should always know what fields there are in a modal anyways