JDA-Applications / JDA-Utilities

A series of tools and utilities for JDA to assist in bot creation
Apache License 2.0
218 stars 111 forks source link

Selection menu enhancement - Added abstract SelectionMenu and ScrollSelection #76

Open JohnnyJayJay opened 6 years ago

JohnnyJayJay commented 6 years ago

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.

Pull Request Information

Check and fill in the blanks for all that apply:

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 Strings 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