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

request: set default action(s) for all pages #768

Open
1 task done
Battlesquid opened this issue Jul 6, 2024 · 1 comment
Open
1 task done

request: set default action(s) for all pages #768

Battlesquid opened this issue Jul 6, 2024 · 1 comment

Comments

@Battlesquid
Copy link

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

I was using PaginatedFieldMessageEmbed and I added my own custom actions (functional equivalents of 'back', 'forward', and 'submit'). Went to run it and I was confused why they weren't showing up. I did some digging and it seems like actions (exlcuding page specific actions) are only added if the number of pages is greater than 1, which in my case they weren't. While this was fine for the 'back' and 'forward' actions, I needed the 'submit' action to show at all times.

Desired solution

It would be nice if there was a method like setPersistentActions that added actions regardless of page count. Alternatively, add a property on PaginatedMessageAction like persistent?: boolean to indicate that the action should persist on all pages.

Alternatives considered

For now, I can work around this limitation by doing the following:

const paginatedEmbed = new PaginatedFieldMessageEmbed()
  .setActions([ /* 'back' and 'forward' actions */ ])
  .make();
const submit: PaginatedMessageActionButton = { /* stuff */ };
for (let i = 0; i < paginatedEmbed.pages.length; i++) {
  paginatedEmbed.addPageAction(submit, i);
}
paginatedEmbed.run(interaction);

Additional context

No response

@favna
Copy link
Member

favna commented Jul 6, 2024

If there is only 1 page then going 1 page forward just loops back to the same one page, same for backwards. The buttons would do nothing and would be purely there for aesthetics and bad UX. That said, you can already achieve this by setting .defaultActions property on the PaginatedMessage (or PaginatedFieldMessageEmbed in your case).

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

No branches or pull requests

3 participants