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

fix: select menu for paginators over 25 pages #1604

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

mifuyutsuki
Copy link
Contributor

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

This fix enables interactions.ext.paginators Paginator with over 25 pages to be used with a select menu, using a "scrolling window" of pages in the paginator select menu.

In this implementation, for a paginator with N pages where N > 25, the first entry in the menu starts moving forward starting Page 13, showing page options 2 to 26. The first entry stops moving forward on page N - 12; if a paginator has 40 pages, the select menu will show page options 16 to 40 starting Page 28.

Changes

  • Edited option enumeration in the Paginator.create_components() section creating the select menu component

Related Issues

#1603

Test Scenarios

Replace the number in range(40) with any number at least 26. The paginator should be sent without errors. Select menu should show only 25 entries, and the option for Page 1 should disappear starting Page 14.

On the other hand, if the number in range(40) is 25 or less, all page options should show, without disappearing options.

from interactions import Client, Embed, slash_command
from interactions.ext.paginators import Paginator

bot = Client()

@slash_command(name="test")
async def test_cmd(ctx):
  embeds = [Embed(title=f"Page {i+1}") for i in range(40)]
  paginator = Paginator.create_from_embeds(bot, *embeds)
  paginator.show_select_menu = True
  await paginator.send(ctx)

bot.start("token")

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

@mifuyutsuki mifuyutsuki changed the title fix: select menu for paginators over 25 pages (#1603) fix: select menu for paginators over 25 pages Feb 15, 2024
Copy link
Member

@AstreaTSS AstreaTSS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is a fix or actually a feature, but regardless, works from basic testing.

@AstreaTSS AstreaTSS merged commit e52af6c into interactions-py:unstable Mar 1, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants