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

Paginator is replaced by second paginator upon using commands consecutively #1269

Closed
3 tasks done
Andell4301 opened this issue Apr 16, 2022 · 2 comments · Fixed by #1270 or #1272
Closed
3 tasks done

Paginator is replaced by second paginator upon using commands consecutively #1269

Andell4301 opened this issue Apr 16, 2022 · 2 comments · Fixed by #1270 or #1272
Assignees
Labels
bug Something isn't working
Projects
Milestone

Comments

@Andell4301
Copy link

Andell4301 commented Apr 16, 2022

Summary

Essentially, if you use a command with a paginator utilizing page groups once, then use the same command with a different option after to produce a different paginator, the second paginator will replace the first in the first commnad.

Reproduction Steps

This bug does not occur if you defer before sending the paginator.

For this to work, you need a command utilizing page groups, and the command needs to have an argument that produces a different paginator depending on the option selected.

To reproduce, simply use the command twice consecutively, the first time with the first option, and the second time with the second option.

After doing this, two scenarios are possible, depending on whether or not the second paginator's page groups are named differently than the first.

Scenario 1, the page groups for the second command are named differently:
In this case, attempting to use the select menu on the first command will fail silently with "this interaction failed". If you then use the first command's buttons (not select menu), they will function properly, but the embeds will be updated as if you were using the second command. Furthermore, the select menu will now be updated to reflect the page group names of the second command, and it will no longer silently fail. The content and view of the first command is now entirely overwritten and identical to the second command.
Scenario 2, the page groups for the second command are named the same:
In this case, the select menu will never silently fail like in the first scenario, but everything else will be the same as scenario 1. The first command's pages will have been completely replaced by the second command's pages.

See the following video for scenario 1 in action:
https://user-images.githubusercontent.com/56235026/163677172-a7b2a0f3-462d-4c37-9e9c-7326d67080a6.mp4

Minimal Reproducible Code

import discord
from discord.ext import pages
bot = discord.Bot()


@bot.slash_command()
async def testing(ctx, option: bool):
    page_groups_option_1 = [
        pages.PageGroup(label="Group 1", pages=[discord.Embed(title="A"), discord.Embed(title="B")], description=""),
        pages.PageGroup(label="Group 2", pages=[discord.Embed(title="C"), discord.Embed(title="D")], description="")
    ]
    page_groups_option_2 = [
        pages.PageGroup(label="Group 3", pages=[discord.Embed(title="E"), discord.Embed(title="F")], description=""),
        pages.PageGroup(label="Group 4", pages=[discord.Embed(title="G"), discord.Embed(title="H")], description="")
    ]

    if option:
        paginator = pages.Paginator(pages=page_groups_option_1, show_menu=True)
    else:
        paginator = pages.Paginator(pages=page_groups_option_2, show_menu=True)

    await paginator.respond(ctx.interaction)

bot.run("TOKEN")

Expected Results

The command instances are totally independent of each other, and they do not overwrite each other.

Actual Results

The second command's paginator overwrites the first command's paginator.

Intents

None

System Information

  • Python v3.10.1-final
  • py-cord v2.0.0-beta
    • py-cord pkg_resources: v2.0.0b7
  • aiohttp v3.8.1
  • system info: Windows 10 10.0.19044

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

@Andell4301 Andell4301 added the unconfirmed bug A bug report that needs triaging label Apr 16, 2022
@krittick krittick self-assigned this Apr 16, 2022
@krittick krittick added bug Something isn't working and removed unconfirmed bug A bug report that needs triaging labels Apr 16, 2022
@krittick krittick added this to the v2.0 milestone Apr 16, 2022
@Andell4301
Copy link
Author

Andell4301 commented Apr 17, 2022

The issue still persists in the following scenario:
Using the minimal reproducible code from before,
use the command twice with different options each time, then before using the select menu of the first command, use the right/left buttons to switch pages. In this scenario, the second paginator will still overwrite the first.

Video:
https://user-images.githubusercontent.com/56235026/163695529-0bd6efbb-57d7-47c9-8f31-7b3cfff90f67.mp4

Also, if you trigger the bug like above, the following exception is raised when the paginator times out:

Task exception was never retrieved
future: <Task finished name='discord-ui-view-timeout-ed8beb24a53200c1f5dce4f12130b0da' coro=<Paginator.on_timeout() done, defined at C:\Users\Andell\Desktop\bot\env\lib\site-packages\discord\ext\pages\pagination.py:469> exception=HTTPException('400 Bad Request (error code: 50035): Invalid Form Body\nIn components.0.components.5: The specified component exceeds the maximum width')>
Traceback (most recent call last):
  File "C:\Users\Andell\Desktop\bot\env\lib\site-packages\discord\ext\pages\pagination.py", line 474, in on_timeout
    await self.message.edit(view=self)
  File "C:\Users\Andell\Desktop\bot\env\lib\site-packages\discord\interactions.py", line 928, in edit
    return await self._state._interaction.edit_original_message(
  File "C:\Users\Andell\Desktop\bot\env\lib\site-packages\discord\interactions.py", line 375, in edit_original_message
    data = await adapter.edit_original_interaction_response(
  File "C:\Users\Andell\Desktop\bot\env\lib\site-packages\discord\webhook\async_.py", line 213, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.5: The specified component exceeds the maximum width

but this does not happen if the bug isn't triggered.

The bug is still not triggered if you defer first. Additionally, after the previous fix, the bug is no longer triggered if you use the select menu first.

@krittick krittick reopened this Apr 17, 2022
@krittick
Copy link
Contributor

What in the world... Will fix.

krittick added a commit that referenced this issue Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
v2.0
  
Awaiting triage
2 participants