AxonCore icon indicating copy to clipboard operation
AxonCore copied to clipboard

Utility: Paginator

Open Khaaz opened this issue 4 years ago • 4 comments

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)

Khaaz avatar Jan 27 '20 17:01 Khaaz

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

john-bv avatar Mar 03 '20 06:03 john-bv

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 avatar Mar 03 '20 17:03 Khaaz

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 avatar Mar 09 '20 15:03 Khaaz

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.

Khaaz avatar Oct 14 '20 21:10 Khaaz