JDA-Utilities icon indicating copy to clipboard operation
JDA-Utilities copied to clipboard

Add EmbedPaginator to menu module

Open Andre601 opened this issue 4 years ago • 2 comments

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:

  • [ ] 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

Closes #103

This implements a EmbedPaginator class to the menu module, which allows to pass own instances of a MessageEmbed to make paginated Embeds.

This is mostly based on the Slideshow class.

There are methods that where not implemented for multiple reasons:

  • setColor and showPageNumber: Seems weird and would probably be a quite "hacky" aproach to alter an Embed's colour if you provide it through the MessageEmbed instance itself.
  • setItemsPerPage: You can only have one embed per page, for obvious reasons.

I also added a addItems(String... items) and setItems(String... items) method to just create a basic Embed with nothing more than the description. That is just a convenience method in case someone wants this.

Andre601 avatar Mar 26 '20 13:03 Andre601

I pushed some minor corrections to the overall format. In addition did I also add a Checks.check(String#length() <= MessageEmbed.TEXT_MAX_LENGTH, "Message"); check for the addItems(String...) and setItems(String...) methods to make sure that none of the provided Strings exceeds the embed limit.

Andre601 avatar Apr 26 '20 19:04 Andre601

Added a addItems(Collection<MessageEmbed>) and setItems(Collection<MessageEmbed>) option.

Andre601 avatar Mar 11 '21 11:03 Andre601