Modal submission help
I am trying to make a modal that asks for your minecraft username and then put it to the database. The modal opens successfully with my one field. But when I click submit it says interaction failed. I couldn't find something in the docs either. No errors in console.
The code: https://pastebin.com/BiURBb6R
Pastebin
const { QuickDB } = require('quick.db');const db = new QuickDB();co...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
41 Replies
- 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!
- ✅
Marked as resolved by OPIf it says it failed, you arent replying to the ModalSubmitInteraction
so this should fix it?
if (!interaction.isModalSubmit()) return;
if (interaction.customId === 'signup_modal') {
await interaction.reply({ content: 'Your submission was received successfully!' });
}
In theory yeah, if thats how/where you want to handle replying
That's werid casue it didn't still the same issue. I have absolutely no idea what I'm doing wrong
Where are you actually handling the response from the modal?
You must want to capture what they wrote
Yeah just reply there
You cant editReply that interaction, since you havent replied to it yet
:method: ModalSubmitInteraction#update()
Updates the original message of the component on which the interaction was received on.
This will probably do what you wanted
What am I doing wrong here?
I dont know, what error are you getting
Same one?
No error just this
I mean no error in console
This is the entire file if that helps
https://pastebin.com/0zY60dYQ
Pastebin
const { QuickDB } = require('quick.db');const db = new QuickDB();co...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Is the collector even firing?
Oh, you're using a message component collector
Modals are not message components
Thats why its not collecting it
How would I do it then?
You can use a regular InteractionCollector, or awaitModalSubmit
why am I getting this error?
await ModalSubmitInteraction.reply("test")
^
TypeError: ModalSubmitInteraction.reply is not a function
at handleSignup (R:\Developer\Discord bots\Foxia\Foxia Events\src\utils\signup.js:33:34)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async InteractionCollector.<anonymous> (R:\Developer\Discord bots\Foxia\Foxia Events\src\Commands\Event\eventCreate.js:73:29)
Node.js v18.17.1
I added this await ModalSubmitInteraction.reply("test")
Uhh because whatever that is, is not a ModalSubmitInteraction
I did something
interaction.awaitModalSubmit({ time: 60000, filter: (interaction) => interaction.isModalSubmit() && interaction.customId === 'signup_modal', })
.then(interaction => interaction.editReply('Thank you for your submission!'))
.catch(err => console.log('No modal submit interaction was collected'));
It says in the console no modal submit interaction was collected. and still the same error in the modal. What is missing here?
Wait does this need to be a client.on?
What does this have to do with the rest of your code
Im so confused
I am trying to get the user provided info from the modal and a reply to the user so the error disappears. But nothing works
You keep changing other parts of your code that aren't what I'm advising. Can you show your collector code currently?
Tried removing the collector code
This isnt a collector
Why did you remove it
Or where is interaction coming from here
I have no idea at this point I am getting very very confused
The pastebin you provided earlier was close to correct, except you used the wrong type of collector
If you changed line 35 from creating a message component collector to
const submit = await interaction.awaitModalSubmit({ filter, time })
etc, it would probably be fine
Then submit.options.getTextInputValue
etcThis error now:
submit.on('collect', async (interaction) => {
^
TypeError: submit.on is not a function
at handleSignup (R:\Developer\Discord bots\Foxia\Foxia Events\src\utils\signup.js:37:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async InteractionCollector.<anonymous> (R:\Developer\Discord bots\Foxia\Foxia Events\src\Commands\Event\eventCreate.js:73:29)
Node.js v18.17.1
Never told you to do that
:guide: Popular Topics: Collectors - Interaction collectors > Await modal submit
If you want to wait for the submission of a modal within the context of another command or button execution, you may find the promisified collector CommandInteraction#awaitModalSubmit()open in new window useful.
read more
Then collector.on is a undefined variable
Yeah because it isnt, this isnt a collector, it awaits one modal submission
submit is the interaction
You also need to put your actual filter and time variable options in there, not copy paste what I did exactly
So I'd remove this?
And fix your filter/time options yeah
and replace interaction.reply with submit.reply?
yeah
Now this error:
R:\Developer\Discord bots\Foxia\Foxia Events\src\utils\signup.js:38
const minecraftUsername = await submit.getTextInputValue('minecraftusername');
^
TypeError: submit.getTextInputValue is not a function
at handleSignup (R:\Developer\Discord bots\Foxia\Foxia Events\src\utils\signup.js:38:48)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async InteractionCollector.<anonymous> (R:\Developer\Discord bots\Foxia\Foxia Events\src\Commands\Event\eventCreate.js:73:29)
Node.js v18.17.1
options.get
sorry, fields.get
finnaly
it works
just some weird db error left
Thanks alot!