Skip to content

feat: General enhancements for views#3093

Open
NeloBlivion wants to merge 160 commits into
Pycord-Development:masterfrom
NeloBlivion:view_additions
Open

feat: General enhancements for views#3093
NeloBlivion wants to merge 160 commits into
Pycord-Development:masterfrom
NeloBlivion:view_additions

Conversation

@NeloBlivion

@NeloBlivion NeloBlivion commented Feb 7, 2026

Copy link
Copy Markdown
Member

Summary

  • replace_item added to DesignerView, ActionRow, Section, Container, and MediaGallery
  • add_item supports positioning with parameters before, after, and index
  • get_item supports getting items by any attribute instead of just id and custom_id
  • Implements Message.get_view to retrieve a stored view or generate a new view
  • Implements len(View) to get the true item count in a view
  • Implements all add_x variants on DesignerView
  • Implements add_text and add_label on DesignerModal
  • Implements DesignerModal.from_dict
  • Added read, save, and to_file to UnfurledMediaItem
  • Added easy conversions for MediaGallery
  • Fixed up some typing

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

@Paillat-dev Paillat-dev self-requested a review April 5, 2026 21:49
@Lulalaby Lulalaby force-pushed the master branch 3 times, most recently from 25347b5 to cc6ebbb Compare April 14, 2026 09:00
@Paillat-dev Paillat-dev force-pushed the master branch 2 times, most recently from 45025bd to 01e9fa8 Compare April 14, 2026 10:21
@Paillat-dev Paillat-dev modified the milestones: 2.9.0, 2.9.0rc1 May 22, 2026

@Icebluewolf Icebluewolf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When checking which items are added to what items it would be useful to not hard code types like (Button, Select). Also some methods are typed to accept ViewItem instead of the specific components that are allowed. This is out of scope for this PR though.

Comment thread discord/ui/action_row.py
or a searched item could not be found in the row.
"""
if sum(x is not None for x in (before, after, index)) > 1:
raise ValueError("Can only specify one of before, after, and index.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This value error is not documented.

Comment thread discord/ui/container.py
A searched item could not be found in the container.
"""
if sum(x is not None for x in (before, after, index)) > 1:
raise ValueError("Can only specify one of before, after, and index.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not documented

Comment thread discord/ui/container.py
if isinstance(original_item, (str, int)):
original_item = self.get_item(original_item)
if not original_item:
raise ValueError(f"Could not find {original_item} in container.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not documented, there are more instances of exceptions not being documented in the new files, but I dont feel like making a comment on each one is necessary.

Comment thread discord/ui/action_row.py
self.children[i] = new_item
original_item.parent = None
except ValueError:
raise ValueError(f"Could not find {original_item} in row.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not documented

Comment thread discord/ui/section.py
The new item to insert into the section.
"""

if not original_item:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This does a truthy check but the error implies it does a isinstance check

Comment thread discord/ui/view.py
children: List[:class:`ViewItem`]
The list of items attached to this view.
disable_on_timeout: :class:`bool`
Whether to disable the view's items when the timeout is reached. Defaults to ``False``.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it would still be an attribute

Comment thread discord/ui/view.py
----------
content: :class:`str`
The content of the TextDisplay
id: Optiona[:class:`int`]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
id: Optiona[:class:`int`]
id: Optional[:class:`int`]

Comment thread discord/ui/view.py
----------
*items: :class:`MediaGalleryItem`
The media this gallery contains.
id: Optiona[:class:`int`]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
id: Optiona[:class:`int`]
id: Optional[:class:`int`]

Comment thread discord/ui/view.py
The URL of this file's media. This must be an ``attachment://`` URL that references a :class:`~discord.File`.
spoiler: Optional[:class:`bool`]
Whether the file has the spoiler overlay. Defaults to ``False``.
id: Optiona[:class:`int`]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
id: Optiona[:class:`int`]
id: Optional[:class:`int`]

Comment thread discord/ui/view.py
----------
*items: Union[:class:`Button`, :class:`Select`]
The items this action row contains.
id: Optiona[:class:`int`]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
id: Optiona[:class:`int`]
id: Optional[:class:`int`]

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

Labels

components Related to discord components (Views + Modals) feature Implements a feature

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Overloads for DesignerView etc

8 participants