Add overloaded getValue method to ModalInteractionEvent #2939
Closed
lajczik
started this conversation in
Feedback & Suggestions
Replies: 1 comment
-
|
The problem with this is that an unfilled |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently,
ModalInteractionEvent#getValue(String id)can returnnull, which forces developers to perform manual null checks before accessing modal values.I propose adding an overloaded version of
getValue- inspired bySlashCommandInteractionEvent#getOption(...)- that allows specifying a fallback value and a mapping function for cleaner and safer access.Proposed Method
Example Usage (new way)
Current Usage (for comparison)
Inspiration
This idea is directly inspired by the
getOption(String name, T defaultValue, Function<OptionMapping, T> mapper)method inSlashCommandInteractionEvent, which provides a consistent and null-safe way to retrieve data from slash commands.Benefits
Beta Was this translation helpful? Give feedback.
All reactions