Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SelectMenu in Modal #2161

Open
3 tasks done
fuma-nama opened this issue Jun 23, 2022 · 4 comments
Open
3 tasks done

Support SelectMenu in Modal #2161

fuma-nama opened this issue Jun 23, 2022 · 4 comments
Labels
status: in progress already in the process of being implemented type: discord issue seems to be an issue on discord's end type: feature

Comments

@fuma-nama
Copy link

fuma-nama commented Jun 23, 2022

General Troubleshooting

  • I have checked for similar issues on the Issue-tracker.
  • I have updated to the latest JDA version
  • I have checked the branches or the maintainers' PRs for upcoming bug fixes.

Expected Behaviour

TextInput and Modal are added in alpha 11,
now Discord API also allows SelectMenu to be used in Modal.
However, JDA failed to parse data when SelectMenu is used in Modal.

The exception is throwed outside the onModalInteraction(ModalInteractionEvent event) method

Exception or Error

[JDA MainWS-ReadThread] WARN WebSocketClient - Got an unexpected Json-parse error. Please redirect the following message to the devs:
	JDA 5.0.0-alpha.12_edbc423
	Unable to resolve value with key value to type String: null
	INTERACTION_CREATE -> {"data":{"components":[{"components":[{"values":["fdws"],"custom_id":"select_todo","type":3}],"type":1}],"custom_id":"1"},"id":"989386933446791179","type":5,"message":{"mention_everyone":false,"pinned":false,"components":[{"components":[{"custom_id":"2","style":1,"label":"Add","type":2},{"custom_id":"3","style":1,"label":"Delete","type":2}],"type":1}],"attachments":[],"author":{"bot":true,"public_flags":0,"id":"907955781972918283","avatar":"d9f145676d8483f0fcb43f25bf0dab0e","username":"BadDog","discriminator":"1660","avatar_decoration":null},"flags":0,"type":20,"mention_roles":[],"application_id":"907955781972918283","edited_timestamp":"2022-06-23T04:30:20.188000+00:00","content":"**TODO List**\n\nfdws\n","tts":false,"webhook_id":"907955781972918283","mentions":[],"interaction":{"name":"todo","id":"989386873183035392","type":2,"user":{"public_flags":256,"id":"572329183334891520","avatar":"278effc51d638314c09e0d611e7be0e3","username":"MONEY","discriminator":"3897","avatar_decoration":null}},"id":"989386874651033600","embeds":[],"channel_id":"959407174591873045","timestamp":"2022-06-23T04:30:12.836000+00:00"},"locale":"en-US","version":1,"user":{"public_flags":256,"id":"572329183334891520","avatar":"278effc51d638314c09e0d611e7be0e3","username":"MONEY","discriminator":"3897","avatar_decoration":null},"channel_id":"959407174591873045","application_id":"907955781972918283","token":"aW50ZXJhY3Rpb246OTg5Mzg2OTMzNDQ2NzkxMTc5OkN6YTN1Zjl1elZpTFJqWHlGU2NNZ0lWdExrcENtbnFtUWQ0U0VWaW8wMXJqY2I1bGNuOFdCNlpwUWlRSFExZkhFbm1ibEdUZE0wSURIZGtkRGRNWW5Cb0NNQUhlcERQVFhkS254Tk5BWjhlU2t6MVdZSWRwb2t0QnlsdmhTbnZI"}
net.dv8tion.jda.api.exceptions.ParsingException: Unable to resolve value with key value to type String: null
	at net.dv8tion.jda.api.utils.data.DataObject.valueError(DataObject.java:807)
	at net.dv8tion.jda.api.utils.data.DataObject.getString(DataObject.java:403)
	at net.dv8tion.jda.api.interactions.modals.ModalMapping.<init>(ModalMapping.java:41)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.IntPipeline$1$1.accept(IntPipeline.java:180)
	at java.base/java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:104)
	at java.base/java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:699)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.IntPipeline$1$1.accept(IntPipeline.java:180)
	at java.base/java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:104)
	at java.base/java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:699)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
	at net.dv8tion.jda.internal.interactions.ModalInteractionImpl.<init>(ModalInteractionImpl.java:50)
	at net.dv8tion.jda.internal.handle.InteractionCreateHandler.handleInternally(InteractionCreateHandler.java:91)
	at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:36)
	at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:957)
	at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:844)
	at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:822)
	at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:996)
	at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:385)
	at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:276)
	at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:996)
	at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:755)
	at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108)
	at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
	at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)
@Xirado
Copy link
Contributor

Xirado commented Jun 23, 2022

Did you manage to send a Modal that contains a SelectMenu with JDA?
Putting them in Modals is not yet officially released nor documented.

@Tais993
Copy link
Contributor

Tais993 commented Jun 23, 2022

Select menus aren't officially supported by Discord, once it's documentation is published JDA will implement it

@MinnDevelopment MinnDevelopment added type: feature status: in progress already in the process of being implemented labels Jun 23, 2022
@MinnDevelopment MinnDevelopment added the type: discord issue seems to be an issue on discord's end label Aug 24, 2022
@Kascald
Copy link

Kascald commented Jul 5, 2024

Are you still experiencing the issue?
I wanted to add a StringSelectMenu to a Modal in the same way, but according to the official documentation (https://jda.wiki/using-jda/interactions/#modals), ''Similarly to messages, Modals can contain up to 5 ActionRows, although the only component that can be put inside Modals at the moment (TextInput) takes up a whole ActionRow.'' This means that only TextInput can be added to modals.

Therefore, I solved this by modifying the process to reply to the interaction with event.reply().addActionRow() upon submitting the modal through onModalInteraction. I added a Button to addActionRow() and used the button interaction to generate a StringSelectMenu. Additionally, if multiple threads access and modify objects during the process, you might want to add measures to handle this.

@MCausc78
Copy link

MCausc78 commented Jul 5, 2024

Are you still experiencing the issue? I wanted to add a StringSelectMenu to a Modal in the same way, but according to the official documentation (https://jda.wiki/using-jda/interactions/#modals), ''Similarly to messages, Modals can contain up to 5 ActionRows, although the only component that can be put inside Modals at the moment (TextInput) takes up a whole ActionRow.'' This means that only TextInput can be added to modals.

Therefore, I solved this by modifying the process to reply to the interaction with event.reply().addActionRow() upon submitting the modal through onModalInteraction. I added a Button to addActionRow() and used the button interaction to generate a StringSelectMenu. Additionally, if multiple threads access and modify objects during the process, you might want to add measures to handle this.

Modals can have only TextInput's. This issue and related PR exist because discord enabled selects in modals by accident

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: in progress already in the process of being implemented type: discord issue seems to be an issue on discord's end type: feature
Projects
None yet
Development

No branches or pull requests

6 participants