Get interaction options values through ModalSubmitInteraction (Modal listener)

Hi I was wondering whether there is any way to retrieve interaction options (slash command options values) through ModalSubmitInteraction? The doc (https://discord.js.org/#/docs/discord.js/main/class/ModalSubmitInteraction) says nothing about it so I am guessing you can't? This is my use case: - I have two interaction listeners: One for slash commands (BaseCommandInteraction) and another for Modals (ModalSubmitInteraction). - When you use a slash command, it takes two inputs from you using options and then it pops up a modal. - The ModalSubmit event (or the whole modal itself) is handled by the Modal listener (ModalSubmitInteraction). - I want to get the values of the 2 options of slash command in Modal listener - But I am not sure the best way to do it - So does anybody know any other way to do it? Thanks in advance 🙂
9 Replies
Unknown User
Unknown User•15mo ago
Message Not Public
Sign In & Join Server To View
edocsil
edocsil•15mo ago
The easiest way would be to use awaitModalSubmit in the command interaction handler and then handle the modal submit in the same scope where you can still access the original command
mz10ah
mz10ah•15mo ago
hmmm, makes sense I wanted to keep the modal and slash commands separate <a:thonk_super_spin:767750585247072286>
edocsil
edocsil•15mo ago
Then you could store the command interactions in a commonly accessible data structure but it would be messier
mz10ah
mz10ah•15mo ago
you mean in a local file?
edocsil
edocsil•15mo ago
For example, attaching a receivedCommands Collection to the Client object so you can do client.receivedCommands.get(key) to reference it in other files
mz10ah
mz10ah•15mo ago
oh I seee yeah the key has to be unique for each slash command executed lot of work 😭 but still I guess a bit better than my solution(s)
edocsil
edocsil•15mo ago
I'd just await the modal personally, but multiple ways to share data
mz10ah
mz10ah•15mo ago
Alrighty Thanks