Modal collecting two responses
I'm coding a bot with discord.js and I would like to prevent my bot from collecting two responses to a modal because we have no way of knowing if the user has canceled his first response and therefore if he completes a second response, it will satisfy the filter of the two interactions and the response will be processed twice.
To solve this I had thought of adding the interaction token in the filter to collect the unique response linked to the interaction. How to add the token in the filter?
24 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!just use the interaction id
so i have to compare the ids of which interactions? do you have an example?
because I thought the id inherited from the slash command and therefore would be the same for both my submits
no id will ever be the same
Each time you use a slash command it will have a different id
interaction id that is
yeah but in this case, it's the same command for both submits
so i will have the same id ?
no
okk
mb
so i compare the id of the interaction and the id of the parent interaction ?
you store the interaction id in the customId of the modal
and
it's the second one the modal interaction
so basically just
.setCustomId(interaction.id)
those arent slash commands
and then my filter is
filter: (int) => int.customId === interaction.id
Those are components
If you are waiting for button or select menu input from a specific message, don't create the collector on the channel.
- Channel collectors return component interactions for any component within that channel.
it's in a slash command and yeah its msg.awaitMessageComponent not i.channel
it quite literally is i.channel
yes but i changed it nvm
but otherwise the two other modifications that I made are correct?
here is the final code
Compare the custom id
and put the interaction id in the modals custom id
with the interaction.id, that's what im doing no ?
no
interaction.id isnt the same as interaction.customId
So its int.customId ?
In my filtrer
And that’s it?
amd change the customid of your modal
Thats what I have done no ?
ah yeah, i looked at the textinput one
Ok so we are good I will test it soon thx for ur help !