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

Utility: Paginator #47

Open
Khaaz opened this issue Jan 27, 2020 · 4 comments
Open

Utility: Paginator #47

Khaaz opened this issue Jan 27, 2020 · 4 comments

Comments

@Khaaz
Copy link
Owner

Khaaz commented Jan 27, 2020

Add a paginator module via reaction (embed or not embed).
Features:

  • custom emoji
  • content per page (easy to use: eg via a function?)
  • timeout

Optional/Interogation:

  • allow asking for a page directly on input (defaut page)
  • page change via different input type (other than emoji)

Goal: paginator used to list items in a message (eg: score etc)
Exported as an independant module (general utility tool)

@john-bv
Copy link
Contributor

john-bv commented Mar 3, 2020

This sounds similar to chunking, is this what you mean?

@Khaaz
Copy link
Owner Author

Khaaz commented Mar 3, 2020

I am not sure what you mean.
The idea here is basically a structure that you create and handle displaying messages.
You input an array or object of embeds or text.
The paginator will then display the correct page depending on the default input, additional input.

This needs to be able to be used with reactions or with messages.
This could be similar to tatsu pagination system for example that display data depending on the page you give.

We could expect from this to also have:

  • a default embed structure, so the only part that change is a small part of the embed (eg: description, fields, description + title) etc
  • some sort of render function that render the embed with dynamic variable: would behave pretty much like tatsu leaderboard: render only the part we want to render, the object itself dynamically pick the data we want to display.
    This could be a second type of paginator.

@Khaaz Khaaz linked a pull request Mar 9, 2020 that will close this issue
7 tasks
@Khaaz
Copy link
Owner Author

Khaaz commented Mar 9, 2020

Quick sum up about what this is supposed to introduce in term of feature:
Paginator:

  • takes a list of embed or pages
  • sends back correct page regarding input:
    • number via awaitMessage / messageCollector
    • reaction via awaitReaction / reactionCollector
    • directly via input (command # return the page for #)

As I see it, we will need various structure:

  • chunker that directly handle the data to output
  • renderer that display the data needed like we want
  • navigator that will take user input and call the rendered to correctly render the data

What could possibly be done:

  • have only one instance of Paginator in the command, that loads and display static (via embed/text). EG: menu, always display the same data

  • Have potentially a default view (embed or text) that takes dynamically data in param and renders it on user input

  • directly use a function in the paginator that will return the data that needs to be displayed (eg: DB call)

  • build dynamically embeds each time and renders it

  • reactionCollector or messageCollector needs to potentially be given in parameter (to use global one / prevent spawning unecessary new listeners)

@Khaaz Khaaz removed the roadmap label Mar 19, 2020
@Khaaz
Copy link
Owner Author

Khaaz commented Oct 14, 2020

Update:

Requirements:

  • DiscordPaginator = abstract class
  • 2 extensions: DiscordMessagePaginator and DiscordReactionPaginator
    You can abstract chunker or whatever else. It just needs at least these 3 classes

Both Paginator works this way:

  • you give them a collector (reaction or message: waiting for the new Collector implementation can be good)
  • you give them a list of page to render as discord embeds
  • you need to be able to have one instance of the paginator per list of pages (aka not having to recreate at every command run) that you call several time to send the pages (I think? but not sure about this one)
  • you need to be able to call the paginator with just the page number for both react and message and it shows the called page. Then it acts as a regular paginator.

There should be a different way to call the paginator (maybe, it can be when you create a generic Paginator and not a MessagePaginator / ReactionPaginator). The only thing I want is that when you call this Paginator with a different method (name TBD), you get the correct page rendered but it doesn't await anything, doesn't put reaction or anything. It just returns the page.

I'd also like a third argument in paginator constructor which is "how the paginator send message" = basically a function that takes a whole embed object (and send it to discord).
There should be a default to that, but the option should be there in case you want to customise it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants