Skip to content

feat: General enhancements for views#3093

Draft
NeloBlivion wants to merge 77 commits intoPycord-Development:masterfrom
NeloBlivion:view_additions
Draft

feat: General enhancements for views#3093
NeloBlivion wants to merge 77 commits intoPycord-Development:masterfrom
NeloBlivion:view_additions

Conversation

@NeloBlivion
Copy link
Member

@NeloBlivion NeloBlivion commented Feb 7, 2026

Summary

Isolates features previously introduced in #3032

  • 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
  • Possibly implement Message.get_view?

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.

@pycord-app
Copy link

pycord-app bot commented Feb 7, 2026

Thanks for opening this pull request!
Please make sure you have read the Contributing Guidelines and Code of Conduct.

This pull request can be checked-out with:

git fetch origin pull/3093/head:pr-3093
git checkout pr-3093

This pull request can be installed with:

pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3093/head

@NeloBlivion NeloBlivion mentioned this pull request Feb 7, 2026
9 tasks
@NeloBlivion NeloBlivion added this to the v2.8 milestone Feb 7, 2026
@NeloBlivion NeloBlivion added feature Implements a feature on hold components Related to discord components (Views + Modals) labels Feb 7, 2026
@Paillat-dev Paillat-dev linked an issue Feb 7, 2026 that may be closed by this pull request
@Paillat-dev
Copy link
Member

What is missing for this to be undrafted ?

The item with the matching ``custom_id``, ``id``, or ``attrs`` if it exists.
"""
if not custom_id:
if not (custom_id or attrs):
Copy link
Member

Choose a reason for hiding this comment

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

This could just be if, elif, else : return None and would be clearer I think ?

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 section.")
Copy link
Member

Choose a reason for hiding this comment

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

Albeit a bit weird, this error would also raise if a user (incorrectly) passes None or another falsy value as original_item. Would not be an issue to care about normally, really, but since we already verify the types for new_item we should probably for original_item ? Idk...


.. warning::

You may specify only **one** of ``index``, ``before``, & ``after``. ``into`` will work together with those parameters.
Copy link
Member

Choose a reason for hiding this comment

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

Could benefit some overloads ig

f"cannot add Select or Button to DesignerView directly. Use ActionRow instead."
)

super().add_item(item)
Copy link
Member

Choose a reason for hiding this comment

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

Is it me or the arguments are just not being used ?

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

None yet

Development

Successfully merging this pull request may close these issues.

Overloads for DesignerView etc

5 participants