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
d.js toolkit
d.js toolkit10mo 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! - Marked as resolved by OP
monbrey
monbrey10mo ago
If it says it failed, you arent replying to the ModalSubmitInteraction
Acemavie
AcemavieOP10mo ago
so this should fix it? if (!interaction.isModalSubmit()) return; if (interaction.customId === 'signup_modal') { await interaction.reply({ content: 'Your submission was received successfully!' }); }
monbrey
monbrey10mo ago
In theory yeah, if thats how/where you want to handle replying
Acemavie
AcemavieOP10mo ago
That's werid casue it didn't still the same issue. I have absolutely no idea what I'm doing wrong
monbrey
monbrey10mo ago
Where are you actually handling the response from the modal? You must want to capture what they wrote
Acemavie
AcemavieOP10mo ago
No description
monbrey
monbrey10mo ago
Yeah just reply there You cant editReply that interaction, since you havent replied to it yet
d.js docs
d.js docs10mo ago
:method: ModalSubmitInteraction#update() Updates the original message of the component on which the interaction was received on.
monbrey
monbrey10mo ago
This will probably do what you wanted
Acemavie
AcemavieOP10mo ago
What am I doing wrong here?
No description
monbrey
monbrey10mo ago
I dont know, what error are you getting Same one?
Acemavie
AcemavieOP10mo ago
No error just this
No description
Acemavie
AcemavieOP10mo ago
I mean no error in console
Acemavie
AcemavieOP10mo ago
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.
monbrey
monbrey10mo ago
Is the collector even firing? Oh, you're using a message component collector Modals are not message components Thats why its not collecting it
Acemavie
AcemavieOP10mo ago
How would I do it then?
monbrey
monbrey10mo ago
You can use a regular InteractionCollector, or awaitModalSubmit
Acemavie
AcemavieOP10mo ago
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")
monbrey
monbrey10mo ago
Uhh because whatever that is, is not a ModalSubmitInteraction
Acemavie
AcemavieOP10mo ago
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?
Acemavie
AcemavieOP10mo ago
Wait does this need to be a client.on?
No description
monbrey
monbrey10mo ago
What does this have to do with the rest of your code Im so confused
Acemavie
AcemavieOP10mo ago
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
monbrey
monbrey10mo ago
You keep changing other parts of your code that aren't what I'm advising. Can you show your collector code currently?
Acemavie
AcemavieOP10mo ago
Tried removing the collector code
No description
monbrey
monbrey10mo ago
This isnt a collector Why did you remove it Or where is interaction coming from here
Acemavie
AcemavieOP10mo ago
I have no idea at this point I am getting very very confused
monbrey
monbrey10mo ago
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 etc
Acemavie
AcemavieOP10mo ago
This 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
monbrey
monbrey10mo ago
Never told you to do that
d.js docs
d.js docs10mo ago
: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
Acemavie
AcemavieOP10mo ago
Then collector.on is a undefined variable
No description
monbrey
monbrey10mo ago
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
Acemavie
AcemavieOP10mo ago
So I'd remove this?
No description
monbrey
monbrey10mo ago
And fix your filter/time options yeah
Acemavie
AcemavieOP10mo ago
and replace interaction.reply with submit.reply?
monbrey
monbrey10mo ago
yeah
Acemavie
AcemavieOP10mo ago
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
monbrey
monbrey10mo ago
options.get sorry, fields.get
Acemavie
AcemavieOP10mo ago
finnaly it works just some weird db error left Thanks alot!
Want results from more Discord servers?
Add your server