getTextInputValue not working :C

client.on("interactionCreate", async (interaction) => {
console.log(interaction.fields.getTextInputValue("request_name"))
});
client.on("interactionCreate", async (interaction) => {
console.log(interaction.fields.getTextInputValue("request_name"))
});
I also checked. This is a modal.
28 Replies
d.js toolkit
d.js toolkit11mo ago
- 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. - Issue solved? Press the button!
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Kasai
Kasai11mo ago
This is working, but Why I cant use: interaction.fields.getTextInputValue('request_name'); Im still getting this error: "TypeError [MODAL_SUBMIT_INTERACTION_FIELD_NOT_FOUND]: Required field with custom id "request_name" not found." const modal_data = new Modal() .setCustomId('modalrequest') .setTitle('Add something to Queue!') .addComponents(new MessageActionRow() .addComponents( new TextInputComponent() .setCustomId('request_name') .setLabel("I want to add:") .setStyle('SHORT') .setMinLength(3) .setMaxLength(150) .setPlaceholder("Enter title or url here..") .setRequired(true) )); await interaction.showModal(modal_data);
d.js docs
d.js docs11mo ago
method BaseInteraction#isModalSubmit() Indicates whether this interaction is a ModalSubmitInteraction
Kasai
Kasai11mo ago
TypeError [MODAL_SUBMIT_INTERACTION_FIELD_NOT_FOUND]: Required field with custom id "request_name" not found.
at ModalSubmitFieldsResolver.getField (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/structures/ModalSubmitFieldsResolver.js:35:23)
at module.exports (/root/01-FILES/discord-bots/bitwave/handlers/erela_events/modal_interactions.js:35:51)
at Client. (/root/01-FILES/discord-bots/bitwave/handlers/erela_events/musicsystem.js:37:79)
at Client.emit (node:events:525:35)
at Client.emit (node:domain:489:12)
at InteractionCreateAction.handle (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/actions/InteractionCreate.js:83:12)
at module.exports [as INTERACTION_CREATE] (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/websocket/WebSocketManager.js:346:31)
at WebSocketShard.onPacket (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/websocket/WebSocketShard.js:493:22)
at WebSocketShard.onMessage (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/websocket/WebSocketShard.js:327:10) {
[Symbol(code)]: 'MODAL_SUBMIT_INTERACTION_FIELD_NOT_FOUND'
}
TypeError [MODAL_SUBMIT_INTERACTION_FIELD_NOT_FOUND]: Required field with custom id "request_name" not found.
at ModalSubmitFieldsResolver.getField (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/structures/ModalSubmitFieldsResolver.js:35:23)
at module.exports (/root/01-FILES/discord-bots/bitwave/handlers/erela_events/modal_interactions.js:35:51)
at Client. (/root/01-FILES/discord-bots/bitwave/handlers/erela_events/musicsystem.js:37:79)
at Client.emit (node:events:525:35)
at Client.emit (node:domain:489:12)
at InteractionCreateAction.handle (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/actions/InteractionCreate.js:83:12)
at module.exports [as INTERACTION_CREATE] (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/websocket/WebSocketManager.js:346:31)
at WebSocketShard.onPacket (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/websocket/WebSocketShard.js:493:22)
at WebSocketShard.onMessage (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/websocket/WebSocketShard.js:327:10) {
[Symbol(code)]: 'MODAL_SUBMIT_INTERACTION_FIELD_NOT_FOUND'
}
yeah... isModalSubmit() is true for me
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Kasai
Kasai11mo ago
no I want to get the value.
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs11mo ago
property ModalSubmitInteraction#customId The custom id of the modal.
Kasai
Kasai11mo ago
yeah now Im only stuck with the interaction.fields.getTextInputValue("field_custom_id")
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Kasai
Kasai11mo ago
Dont wonder. Its in an extra file.
client.on("interactionCreate", async (interaction) => {
if (interaction.isModalSubmit()) return require("./modal_interactions.js")(client, interaction)
});
client.on("interactionCreate", async (interaction) => {
if (interaction.isModalSubmit()) return require("./modal_interactions.js")(client, interaction)
});
the other file:
module.exports = async (client, interaction) => {
console.log(interaction.fields.getTextInputValue("request_name"))
};
module.exports = async (client, interaction) => {
console.log(interaction.fields.getTextInputValue("request_name"))
};
I only have one modal so I dont need to check the customid for Submit Interaction
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Kasai
Kasai11mo ago
yes :c the problem is this in the source code from discod.js: I checked the source code and logged "interaction.fields": {"components":[{"type":"ACTION_ROW","components":[{"value":"fghfhfghfghhgjgh","type":"TEXT_INPUT"}]}]} and there is no customId property
getField(customId) {
const field = this._fields.find(f => f.customId === customId);
if (!field) throw new TypeError('MODAL_SUBMIT_INTERACTION_FIELD_NOT_FOUND', customId);
return field;
}
getField(customId) {
const field = this._fields.find(f => f.customId === customId);
if (!field) throw new TypeError('MODAL_SUBMIT_INTERACTION_FIELD_NOT_FOUND', customId);
return field;
}
And I logged this._fields:
[{"value":"my text","type":"TEXT_INPUT"}]
[{"value":"my text","type":"TEXT_INPUT"}]
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Kasai
Kasai11mo ago
yeah wait...
Kasai
Kasai11mo ago
SourceBin
getTextInputValue error
Instantly share your code with the world.
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Kasai
Kasai11mo ago
oh sry I forgot :c
Kasai
Kasai11mo ago
SourceBin
getTextInputValue error
Instantly share your code with the world.
Kasai
Kasai11mo ago
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Kasai
Kasai11mo ago
no problem but many people here have this problem in v13 I used guide from the website (copied and pasted):
onst { MessageActionRow, Modal, TextInputComponent } = require('discord.js');

client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction.commandName === 'ping') {
// Create the modal
const modal = new Modal()
.setCustomId('myModal')
.setTitle('My Modal');
// Add components to modal
// Create the text input components
const favoriteColorInput = new TextInputComponent()
.setCustomId('favoriteColorInput')
// The label is the prompt the user sees for this input
.setLabel("What's your favorite color?")
// Short means only a single line of text
.setStyle('SHORT');
const hobbiesInput = new TextInputComponent()
.setCustomId('hobbiesInput')
.setLabel("What's some of your favorite hobbies?")
// Paragraph means multiple lines of text.
.setStyle('PARAGRAPH');
// An action row only holds one text input,
// so you need one action row per text input.
const firstActionRow = new MessageActionRow().addComponents(favoriteColorInput);
const secondActionRow = new MessageActionRow().addComponents(hobbiesInput);
// Add inputs to the modal
modal.addComponents(firstActionRow, secondActionRow);
// Show the modal to the user
await interaction.showModal(modal);
}
});
onst { MessageActionRow, Modal, TextInputComponent } = require('discord.js');

client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction.commandName === 'ping') {
// Create the modal
const modal = new Modal()
.setCustomId('myModal')
.setTitle('My Modal');
// Add components to modal
// Create the text input components
const favoriteColorInput = new TextInputComponent()
.setCustomId('favoriteColorInput')
// The label is the prompt the user sees for this input
.setLabel("What's your favorite color?")
// Short means only a single line of text
.setStyle('SHORT');
const hobbiesInput = new TextInputComponent()
.setCustomId('hobbiesInput')
.setLabel("What's some of your favorite hobbies?")
// Paragraph means multiple lines of text.
.setStyle('PARAGRAPH');
// An action row only holds one text input,
// so you need one action row per text input.
const firstActionRow = new MessageActionRow().addComponents(favoriteColorInput);
const secondActionRow = new MessageActionRow().addComponents(hobbiesInput);
// Add inputs to the modal
modal.addComponents(firstActionRow, secondActionRow);
// Show the modal to the user
await interaction.showModal(modal);
}
});
Always the same error: Error: I can't find this field 1|BITWAVE | at ModalSubmitFieldsResolver.getTextInputValue (/root/01-FILES/discord-bots/bitwave/node_modules/discord-modal/ModalSubmitFieldsResolver.js:18:50) 1|BITWAVE | at Client.<anonymous> (/root/01-FILES/discord-bots/bitwave/handlers/extraevents.js:233:68) 1|BITWAVE | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 1|BITWAVE | 1|BITWAVE | === UNHANDLED REJECTION === 1|BITWAVE | Reason: 1|BITWAVE | === UNHANDLED REJECTION === 1|BITWAVE | 1|BITWAVE | TypeError [MODAL_SUBMIT_INTERACTION_FIELD_NOT_FOUND]: Required field with custom id "test" not found. 1|BITWAVE | at ModalSubmitFieldsResolver.getField (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/structures/ModalSubmitFieldsResolver.js:34:23) 1|BITWAVE | at ModalSubmitFieldsResolver.getTextInputValue (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/structures/ModalSubmitFieldsResolver.js:44:24) 1|BITWAVE | at module.exports (/root/01-FILES/discord-bots/bitwave/handlers/erela_events/modal_interactions.js:32:46) 1|BITWAVE | at Client.<anonymous> (/root/01-FILES/discord-bots/bitwave/handlers/erela_events/musicsystem.js:36:79) 1|BITWAVE | at Client.emit (node:events:525:35) 1|BITWAVE | at Client.emit (node:domain:489:12) 1|BITWAVE | at InteractionCreateAction.handle (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/actions/InteractionCreate.js:83:12) 1|BITWAVE | at module.exports [as INTERACTION_CREATE] (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36) 1|BITWAVE | at WebSocketManager.handlePacket (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/websocket/WebSocketManager.js:346:31) 1|BITWAVE | at WebSocketShard.onPacket (/root/01-FILES/discord-bots/bitwave/node_modules/discord.js/src/client/websocket/WebSocketShard.js:493:22) { 1|BITWAVE | [Symbol(code)]: 'MODAL_SUBMIT_INTERACTION_FIELD_NOT_FOUND'
I logged the: "TextInputComponent" and the output is: {"custom_id":"test","label":"What's your favorite color?","max_length":null,"min_length":null,"placeholder":null,"required":false,"style":1,"type":4,"value":null}
It doesn't render properly in interaction.fields
Kasai
Kasai11mo ago
There is an error in the source code from discord.js
static transformComponent(rawComponent) {
return rawComponent.components.map(c => ({
value: c.value,
type: MessageComponentTypes[c.type],
customId: c.customId, // << was c.custom_id before
}));
}
static transformComponent(rawComponent) {
return rawComponent.components.map(c => ({
value: c.value,
type: MessageComponentTypes[c.type],
customId: c.customId, // << was c.custom_id before
}));
}
https://github.com/discordjs/discord.js/blob/cb11c56a0b93c802b024cc9c8d95250ddf1a5246/src/structures/ModalSubmitInteraction.js#L93 Now TextInputComponent() and getField() get the customId again!
GitHub
discord.js/src/structures/ModalSubmitInteraction.js at cb11c56a0b93...
A powerful JavaScript library for interacting with the Discord API - discordjs/discord.js
duck
duck11mo ago
that's not a typo that function should only be receiving the raw component data from discord, and the discord api uses snake_case at no point should that data contain the property customId unless either discord had an issue, or if other discord.js internal source was modified I am unable to reproduce any behavior requiring the change you've provided
Kasai
Kasai11mo ago
I dont have my pc now here but I also tried a new bot with one file with the discord js guide and copied & pasted it this here
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
Kasai
Kasai11mo ago
Yeah I know but I changed it to offical version I thought I will look tomorrow into it again But the thing is that I have this in my discord. js and not in the package discord-modal. I'm really confused now. oh lol I think I got it in my brain before sleeping xD the initialize with DiscordModal(client) was still active and I forgot to disable it. Sry. I will try this tomorrow. But thanks for your help. sometimes it's the smallest and dumbest mistakes Yeah it works now. Thanks