JDA-Utilities
JDA-Utilities copied to clipboard
Selection menu enhancement - Added abstract SelectionMenu and ScrollSelection
Pull Request
Pull Request Checklist
Please follow the following steps before opening this PR.
PRs that do not complete the checklist will be subject to denial for
missing information.
- [x] I have checked the pull request page for upcoming or merged features/bug fixes.
- [x] I have read JDA's contributing guidelines.
Pull Request Information
Check and fill in the blanks for all that apply:
- [ ] My PR fixes a bug, error, or other issue with the library's codebase.
- [x] My PR is for the
menu
module of the JDA-Utilities library. - [ ] My PR creates a new module for the JDA-Utilities library:
______
.
Description
This PR re-structures the SelectionDialog.
There is a new abstract class called SelectionMenu
that allows easier implementations for menus with selections. The code for SelectionMenu
is mainly taken from the former SelectionDialog
, as every SelectionMenu
basically works like it.
When making new extensions of SelectionMenu
, the only difference should be the Builder and the render(int)
method, which is declared abstract in SelectionMenu
. It is also possible to overwrite the new method getNewSelection(Message, String, int)
for other possible reactions. Configuring the reactions is not up to the user yet, however you have to pass a List of Strings (the unicode emojis) to the SelectionMenu
constructor to set the reactions that are available. Currently, this is done internally.
In this PR, a new SelectionMenu
is already included: the ScrollSelection
.
The ScrollSelection
is similar to SelectionDialog
, but it only shows the currently selected entry. Also, the content of the embed description is configurable with a format String.
I also added a new method for all SelectionMenu
Builders, setChoices(List<String>)
.
The contents of Kantenkugel's recent PR are also included and function correctly.
All of this is fully mergeable with the current master branch. Existing code will still work, too.
~~, with one exception: The public static final String
s in SelectionDialog
are gone, they are now in SelectionMenu
. They can still be added again and immediately deprecated to avoid any inconvenience~~.
Update: Added them again for convenience