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

Components get moved randomly in a full Action Row on message/view update #7231

Closed
3 tasks done
Luc1412 opened this issue Jul 14, 2021 · 1 comment
Closed
3 tasks done
Labels
bug This is a bug with the library.

Comments

@Luc1412
Copy link
Contributor

Luc1412 commented Jul 14, 2021

Summary

The 3 Link buttons get moved into the Select ActionRow which causes an error

Reproduction Steps

  1. Use the following code below and start the view
  2. select the 2nd select item multiple times
  3. An error will randomly? occur

Minimal Reproducible Code

class TestView(discord.ui.View):

    def __init__(self):
        super().__init__()
        help_select = discord.ui.Select(options=[
            discord.SelectOption(label='Home', value='home', emoji='🏠', default=True),
            discord.SelectOption(label='Name', value='stats', emoji='📊'),
        ])
        help_select.callback = self.select_page
        self.add_item(help_select)

        self.add_item(discord.ui.Button(style=discord.ButtonStyle.url, label='Example 1', url=f'https://youtube.com'))
        self.add_item(discord.ui.Button(style=discord.ButtonStyle.url, label='Example 2', url='https://discord.com'))
        self.add_item(discord.ui.Button(style=discord.ButtonStyle.url, label='Example 3', url='https://google.com'))

    async def select_page(self, interaction: discord.Interaction):
        select: discord.ui.Select = discord.utils.get(self.children, custom_id=interaction.data['custom_id'])
        if not select.values:
            return
        await interaction.message.edit(view=self)

Expected Results

The components just normally update.

to_components() looks like:
[{'type': 1, 'components': [{'type': 3, 'custom_id': 'f0a5a63f62e6b58e179eadba3014652b', 'min_values': 1, 'max_values': 1, 'options': [{'label': 'Home', 'value': 'home', 'default': True, 'emoji': {'name': '🏠'}}, {'label': 'Name', 'value': 'stats', 'default': False, 'emoji': {'name': '📊'}}]}]}, {'type': 1, 'components': [{'type': 2, 'style': 5, 'label': 'Example 1', 'disabled': False, 'url': 'https://youtube.com'}, {'type': 2, 'style': 5, 'label': 'Example 2', 'disabled': False, 'url': 'https://discord.com'}, {'type': 2, 'style': 5, 'label': 'Example 3', 'disabled': False, 'url': 'https://google.com'}]}]

Actual Results

An error occurrs:

Ignoring exception in view <TestView timeout=180.0 children=4> for item <Select placeholder=None min_values=1 max_values=1 options=[<SelectOption label='Home' value='home' description=None emoji=<PartialEmoji animated=False name='🏠' id=None> default=True>, <SelectOption label='Name' value='stats' description=None emoji=<PartialEmoji animated=False name='📊' id=None> default=False>]>:
Traceback (most recent call last):
  File "C:\Users\Lucas Hardt\Development\EasySystem\EasyFnStatsV3\venv\lib\site-packages\discord\ui\view.py", line 358, in _scheduled_task
    await item.callback(interaction)
  File "C:\Users\Lucas Hardt\Development\EasySystem\EasyFnStatsV3\utils\views.py", line 2516, in select_page
    await interaction.message.edit(view=self)
  File "C:\Users\Lucas Hardt\Development\EasySystem\EasyFnStatsV3\venv\lib\site-packages\discord\message.py", line 1249, in edit
    data = await self._state.http.edit_message(self.channel.id, self.id, **payload)
  File "C:\Users\Lucas Hardt\Development\EasySystem\EasyFnStatsV3\venv\lib\site-packages\discord\http.py", line 337, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.1: The specified component exceeds the maximum width
In components.0.components.2: The specified component exceeds the maximum width
In components.0.components.3: The specified component exceeds the maximum width

to_components() looks like:
[{'type': 1, 'components': [{'type': 3, 'custom_id': 'f0a5a63f62e6b58e179eadba3014652b', 'min_values': 1, 'max_values': 1, 'options': [{'label': 'Home', 'value': 'home', 'default': True, 'emoji': {'name': '🏠'}}, {'label': 'Name', 'value': 'stats', 'default': False, 'emoji': {'name': '📊'}}]}, {'type': 2, 'style': 5, 'label': 'Example 1', 'disabled': False, 'url': 'https://youtube.com'}, {'type': 2, 'style': 5, 'label': 'Example 2', 'disabled': False, 'url': 'https://discord.com'}, {'type': 2, 'style': 5, 'label': 'Example 3', 'disabled': False, 'url': 'https://google.com'}]}]
occurs

Intents

guilds, members, emojis, webhooks, voice_states, guild_messages, guild_reactions, dm_messages, dm_reactions

System Information

  • Python v3.9.0-final
  • discord.py v2.0.0-alpha
    • discord.py pkg_resources: v2.0.0a0
  • aiohttp v3.7.4.post0
  • system info: Windows 10 10.0.22000

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

@Luc1412 Luc1412 added the unconfirmed bug A bug report that needs triaging label Jul 14, 2021
@Luc1412 Luc1412 changed the title Components get moved randomly in a full Action Row on message/view Components get moved randomly in a full Action Row on message/view update Jul 14, 2021
@Rapptz Rapptz linked a pull request Jul 27, 2021 that will close this issue
6 tasks
@Rapptz Rapptz removed a link to a pull request Jul 28, 2021
6 tasks
@Luc1412
Copy link
Contributor Author

Luc1412 commented Mar 6, 2022

I found a solution for this problem a while ago. I'll open a pr soon. Thanks for coming back!

@Rapptz Rapptz closed this as completed in e198a0e Apr 27, 2022
@Rapptz Rapptz added bug This is a bug with the library. and removed unconfirmed bug A bug report that needs triaging labels Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is a bug with the library.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants