feat: General enhancements for views#3093
Conversation
* fix(actions): rework release workflow * style(pre-commit): auto fixes from pre-commit.com hooks --------- Co-Authored-By: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: Lala Sabathil <lala@pycord.dev>
25347b5 to
cc6ebbb
Compare
45025bd to
01e9fa8
Compare
Signed-off-by: Nelo <41271523+NeloBlivion@users.noreply.github.com>
Signed-off-by: Nelo <41271523+NeloBlivion@users.noreply.github.com>
Icebluewolf
left a comment
There was a problem hiding this comment.
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.
| 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.") |
There was a problem hiding this comment.
This value error is not documented.
| 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.") |
| 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.") |
There was a problem hiding this comment.
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.
| self.children[i] = new_item | ||
| original_item.parent = None | ||
| except ValueError: | ||
| raise ValueError(f"Could not find {original_item} in row.") |
| The new item to insert into the section. | ||
| """ | ||
|
|
||
| if not original_item: |
There was a problem hiding this comment.
This does a truthy check but the error implies it does a isinstance check
| 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``. |
There was a problem hiding this comment.
it would still be an attribute
| ---------- | ||
| content: :class:`str` | ||
| The content of the TextDisplay | ||
| id: Optiona[:class:`int`] |
There was a problem hiding this comment.
| id: Optiona[:class:`int`] | |
| id: Optional[:class:`int`] |
| ---------- | ||
| *items: :class:`MediaGalleryItem` | ||
| The media this gallery contains. | ||
| id: Optiona[:class:`int`] |
There was a problem hiding this comment.
| id: Optiona[:class:`int`] | |
| id: Optional[:class:`int`] |
| 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`] |
There was a problem hiding this comment.
| id: Optiona[:class:`int`] | |
| id: Optional[:class:`int`] |
| ---------- | ||
| *items: Union[:class:`Button`, :class:`Select`] | ||
| The items this action row contains. | ||
| id: Optiona[:class:`int`] |
There was a problem hiding this comment.
| id: Optiona[:class:`int`] | |
| id: Optional[:class:`int`] |
Summary
replace_itemadded toDesignerView,ActionRow,Section,Container, andMediaGalleryadd_itemsupports positioning with parametersbefore,after, andindexget_itemsupports getting items by any attribute instead of justidandcustom_idMessage.get_viewto retrieve a stored view or generate a new viewlen(View)to get the true item count in a viewadd_xvariants on DesignerViewadd_textandadd_labelon DesignerModalDesignerModal.from_dictread,save, andto_filetoUnfurledMediaItemInformation
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.