Repository: Pycord-Development/pycord

Issue:
Paginator is replaced by second paginator upon using commands consecutively
### 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

```python
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

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

_No response_
Paginator is replaced by second paginator upon using commands consecutively
### 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

```python
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

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

_No response_


Discussion:
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.
What in the world... Will fix. 
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.
What in the world... Will fix. 

Resolving patch:
diff --git a/discord/ext/pages/pagination.py b/discord/ext/pages/pagination.py
--- a/discord/ext/pages/pagination.py
+++ b/discord/ext/pages/pagination.py
@@ -591,7 +591,6 @@ def add_default_buttons(self):
                 label="<<",
                 style=discord.ButtonStyle.blurple,
                 row=self.default_button_row,
-                custom_id="pages_first_button",
             ),
             PaginatorButton(
                 "prev",
@@ -599,14 +598,12 @@ def add_default_buttons(self):
                 style=discord.ButtonStyle.red,
                 loop_label="↪",
                 row=self.default_button_row,
-                custom_id="pages_prev_button",
             ),
             PaginatorButton(
                 "page_indicator",
                 style=discord.ButtonStyle.gray,
                 disabled=True,
                 row=self.default_button_row,
-                custom_id="pages_indicator_button",
             ),
             PaginatorButton(
                 "next",
@@ -614,14 +611,12 @@ def add_default_buttons(self):
                 style=discord.ButtonStyle.green,
                 loop_label="↩",
                 row=self.default_button_row,
-                custom_id="pages_next_button",
             ),
             PaginatorButton(
                 "last",
                 label=">>",
                 style=discord.ButtonStyle.blurple,
                 row=self.default_button_row,
-                custom_id="pages_last_button",
             ),
         ]
         for button in default_buttons:


Test patch: