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•2y ago
Message Not Public
Sign In & Join Server To View
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
hmmm, makes sense
I wanted to keep the modal and slash commands separate <a:thonk_super_spin:767750585247072286>
Then you could store the command interactions in a commonly accessible data structure but it would be messier
you mean in a local file?
For example, attaching a receivedCommands Collection to the Client object so you can do client.receivedCommands.get(key) to reference it in other files
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)
I'd just await the modal personally, but multiple ways to share data
Alrighty
Thanks