Paginated message help
Hey, is there a way to change the items of the pagination message? Ideally with the PaginationFieldMessageEmbed. The use case is I want to build up an inventory for a RPG and want separate categories (to be selected using SelectMenu) At a given time, only one type of category would be shown.. Is there a way to swap out the old items and replace with brand new ones?
8 Replies
Assuming that you mean that each category is a page, use addPageAction https://www.sapphirejs.dev/docs/Documentation/api-utilities/classes/sapphire_discord_js_utilities.PaginatedMessage#addpageaction
I meant more as there would be multiple paginatedMessage objects and if the user selects a new category, the whole message would be edited and replaced
Uh no we do not support that, I'm sorry.
Another question: is there a way to add a cooldown for button interactions?
there isnt. There is an open PR after which you can use sapphire interaction handlers instead of the action's
run
though so then you can reply to an interaction saying they need to wait and just don't process it further. You'll have to implement the rate limit yourself still. Not too dissimilar from https://www.sapphirejs.dev/docs/Guide/plugins/API/rate-limitingSapphire Framework
Applying rate limits to routes | Sapphire
When writing an API that is publicly available for consumption, it is often desirable to set a rate limit on your routes
As Favna said, it'll be possible if/when the PR is merged. For normal buttons, I've implemented it myself using
RateLimitManager
and decorators in an interaction handler.
Example: https://github.com/KBot-discord/KBot/blob/4862ca8dff95b95363d24e33a70d294c1eb41599/apps/bot/src/lib/utilities/decorators.ts#L26
Actually, I guess you could throw that logic into the action's run
but that could be repetitive.kk one more.. question: how can i make a button disabled if its on the first page or last page?
I assume this can be done via setting page specific actions but wondering if theres an easier solution
your assumption is correct
@sam the update that KB mentioned has been released, see #Announcements