PaginatedMessage to fetch data on demand

Is there an example on how to make a PaginatedMessage fetch data for a page when it is called? I dont want to get all the data from the db at once since its too slow.
8 Replies
secre
secre2w ago
Maybe you could add custom actions with your code for fetching data and then editing page with your embed, idk Like there, look at custom actions Idk if you can edit message in there so you need to try it out by yourself
čamdžić
čamdžić2w ago
There is LazyPaginatedMessage
čamdžić
čamdžić2w ago
This is a LazyPaginatedMessage. Instead of resolving all pages that are functions on PaginatedMessage.run will resolve when requested. It’s not greatest way and it’s probably not what you want But still much better than normal PaginatedMessage You probahly want dynamic paginated message but sadly it’s not available on Sapphire
Favna
Favna5d ago
Correct me if I'm wrong but I believe you're saying this because of the discussion we had in the past and even then I also said you were wrong and LazyPaginatedMessage is the correct thing to be used here but I don't think I got my message across then either and that's biting us in the back now :\
čamdžić
čamdžić5d ago
LazyPaginatedMessage is okay, and 100% can be used, but the problem is that I will still have all those functions in pages array DynamicPaginatedMessage calls one function with currentPage parameter and gets data for that page only when page is changed Only ONE function With lazy it can be 1000 functions because there are 1000 pages
Favna
Favna5d ago
and there is nothing wrong with that. That is perfectly normal JavaScript code. used to be classes were glorified functions and any methods on classes were functions on functions on functions so I hardly see the problem here at any rate, you're free to publish your DynamicPaginatedMessage as your own package but I don't think we'll want to merge it to main for sapphire (not that there is a PR for it now anyway)
čamdžić
čamdžić5d ago
👍

Did you find this page helpful?