Modal Listeners "stealing" Interactions from each other

I have the following problem: When a user executes an interaction, the bot shows a modal and then uses awaitModalSubmit() to await a response. However, if the user closes the modal (which won't give the bot anything) and then executes a different command which also shows a modal (and then listens for a response), the first listener will snatch the response of the user and continue execution while the second one throws the error InteractionAlreadyReplied (which is understandable, because the first listener stole it). I've tried making a check with the interaction's ID, but the initial interaction ID is different compared to the ModalSubmit interaction ID. Is there a way to prevent the listeners stealing each other's interactions?
6 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
lupus
lupus2y ago
It's quite difficult to show the code for this, I hope it's understandable. I do have a check to verify that the user is the same.
Syjalo
Syjalo2y ago
Add a filter to the await collector
lupus
lupus2y ago
Hey, I have a filter setup which filters for the User ID. However, I'm not quite sure how to filter in regards to the (parent) interaction, could you point me in the right direction here? Specifically, which property should I compare to make sure that the interaction is correct.
Syjalo
Syjalo2y ago
Add interaction.id to the modal's custom id
lupus
lupus2y ago
Oh, that's an interesting approach. Thank you for the suggestion, I'll try that :D