Skip to content

Components V2 #10166

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

Open
wants to merge 114 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 80 commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
ae2410f
feat: Components V2
DA-344 Feb 18, 2025
b2f77b9
Merge branch 'master' of https://github.com/rapptz/discord.py
DA-344 Feb 18, 2025
7513456
feat: First components v2 commit
DA-344 Feb 28, 2025
335b397
chore: Update components
DA-344 Mar 1, 2025
ce3f48e
fix: License quotes
DA-344 Mar 1, 2025
eea95d9
chore: Add more components and some things on weights and so
DA-344 Mar 1, 2025
8689718
chore: more things to components v2
DA-344 Mar 1, 2025
76e2028
chore: More v2 components on UI and idk some changes
DA-344 Mar 1, 2025
b872925
chore: Remove views things
DA-344 Mar 2, 2025
4467eba
chore: Donnot subclass AttachmentBase and fake payload for Attachment…
DA-344 Mar 2, 2025
4aef97e
chore: undo attachment file move
DA-344 Mar 2, 2025
0f04d48
chore: Remove views leftover
DA-344 Mar 2, 2025
2b14f0b
chore: message attachments things
DA-344 Mar 2, 2025
f42b15f
chore: Remove attachment.py
DA-344 Mar 2, 2025
39998b4
chore: Revert double quotes
DA-344 Mar 2, 2025
28efb15
chore: Finished first components v2 impl
DA-344 Mar 2, 2025
de8a723
chore: docs and some changes
DA-344 Mar 2, 2025
7824c3f
chore: fix everything lol
DA-344 Mar 2, 2025
5d1300d
fix: documentation errors
DA-344 Mar 2, 2025
a1bc73b
fix: add SeparatorComponent to __all__
DA-344 Mar 2, 2025
14d8f31
chore: Add missing enums to docs and fix docstrings
DA-344 Mar 2, 2025
4202ef4
chore: Format ValueError no row.setter to show the maxrow and not 10
DA-344 Mar 2, 2025
15ec28b
chore: yet more docs fix
DA-344 Mar 2, 2025
86d967c
fix: Docs failing due to :class:
DA-344 Mar 2, 2025
e7693d9
chore: buttons cannot be outside action rows
DA-344 Mar 2, 2025
5fda19e
chore: add ui.Section.is_dispatchable
DA-344 Mar 2, 2025
0a03968
chore: fix errors
DA-344 Mar 2, 2025
a4389cb
chore: Revert change View.to_components() sorting key
DA-344 Mar 2, 2025
70bdcfa
chore: Update item _view attr and # type: ignore self.accessory in se…
DA-344 Mar 2, 2025
568a3c3
chore: Run black
DA-344 Mar 2, 2025
bfae3a5
chore: Make type the first key on to_components_dict
DA-344 Mar 2, 2025
869b68f
fix: _ViewWeights.v2_weights always returning False
DA-344 Mar 2, 2025
faa31ff
chore: Add notes and versionaddeds
DA-344 Mar 2, 2025
18f72f5
idk some things
DA-344 Mar 4, 2025
cbdc618
chore: Finish ActionRow and fix ViewStore.add_view
DA-344 Mar 6, 2025
8f59216
chore: more components v2 things and finished danny's suggested impl
DA-344 Mar 6, 2025
6c02a7d
chore: docs
DA-344 Mar 6, 2025
67bfa57
chore: run black
DA-344 Mar 6, 2025
0b23f10
chore: fix discord.ui.View
DA-344 Mar 6, 2025
eae0895
chore: fix linting
DA-344 Mar 6, 2025
c63ad95
chore: more linting things and docs
DA-344 Mar 6, 2025
7338da2
fix linting yet again
DA-344 Mar 6, 2025
c5ffc6a
chore: fix LayoutView.to_components
DA-344 Mar 7, 2025
59991e9
chore: fix Container.to_components returning NotImplemented
DA-344 Mar 7, 2025
502051a
chore: update ActionRow and View
DA-344 Mar 7, 2025
f1f6ef8
chore: remove unused imports
DA-344 Mar 7, 2025
9e18c5a
chore: typing stuff
DA-344 Mar 7, 2025
e660010
chore: more typing stuff
DA-344 Mar 7, 2025
c48c512
chore: some fixes of bugs reported on the bikeshedding post
DA-344 Mar 9, 2025
8cb80bf
chore: improve check on container.__init_subclass__
DA-344 Mar 9, 2025
7601533
chore: add id attr to components and black item.py
DA-344 Mar 9, 2025
9891f85
chore: add id to every item
DA-344 Mar 9, 2025
c93ee07
fix: Container._colour raising ValueError
DA-344 Mar 9, 2025
09fceae
fix: Container.is_dispatchable making buttons not work
DA-344 Mar 9, 2025
8399677
fix: Container children not being added to view store
DA-344 Mar 9, 2025
9700606
chore: Update Container._update_store_data
DA-344 Mar 9, 2025
0f7d72b
chore: Update Container.is_dispatchable
DA-344 Mar 9, 2025
cf4db91
chore: Remove unused imports
DA-344 Mar 9, 2025
6d50c88
chore: Metadata for Section
DA-344 Mar 9, 2025
9655749
fix: Section.accessory not being dispatched
DA-344 Mar 9, 2025
5120b0d
chore: Update ViewStore to handle Section.accessory properly
DA-344 Mar 10, 2025
4c668ba
template
DA-344 Mar 10, 2025
84ad47f
chore: Remove unneccessary # type: ignore
DA-344 Mar 10, 2025
7433ad0
chore: Fix Section.accessory raising an error when clicked
DA-344 Mar 10, 2025
810fe57
chore: Update container to also take in account section accessories
DA-344 Mar 10, 2025
52f9b6a
chore: Some changes on how Section.accessory is handled in Container
DA-344 Mar 10, 2025
8561953
chore: Add container add/remove/clear_item(s)
DA-344 Mar 10, 2025
8926f28
fix: Section.accessory._view being None when in a container
DA-344 Mar 10, 2025
b1e8aef
fix: Containers not dispatching ActionRow items correctly
DA-344 Mar 10, 2025
4c662a9
chore: Some changes, fixes, and typo corrections
DA-344 Mar 20, 2025
dddf502
Merge branch 'feat/components-v2' of https://github.com/DA-344/d.py i…
DA-344 Mar 20, 2025
a93a639
Merge branch 'master' of https://github.com/rapptz/discord.py into fe…
DA-344 Mar 20, 2025
4ef1e46
chore: Add ActionRow to docs
DA-344 Mar 20, 2025
86dd8d8
chore: Add get_item_by_id to remaining items
DA-344 Apr 16, 2025
cd9f776
some fixes and typings
DA-344 Apr 18, 2025
5dddf65
run black
DA-344 Apr 18, 2025
a1216e7
fix error when using Message.components
DA-344 Apr 18, 2025
cba602d
chore: Add more params to MessageFlags.components_v2 docstring
DA-344 Apr 18, 2025
e9d942b
chore: typings
DA-344 Apr 18, 2025
ec186ab
chore: update docstrings
DA-344 Apr 18, 2025
b0bab6d
fix: `children` parameter being ignored on Container
DA-344 Apr 19, 2025
412caa6
update ActionRow.select docstring
DA-344 Apr 19, 2025
9026bcb
add note about Item.custom_id
DA-344 Apr 19, 2025
cf949c6
chore: some bunch fixes and make interaction_check's work on every item
DA-344 Apr 19, 2025
fb8e85d
fix: typings
DA-344 Apr 19, 2025
fe7d7f2
chore: Update view param docstring on send methods
DA-344 Apr 19, 2025
195b9e7
chore: Allow ints on accent_colo(u)r on Container's
DA-344 Apr 19, 2025
7028911
fix: Item.view not being correctly set when using 'add_item' methods
DA-344 Apr 19, 2025
86ec834
chore: Update BaseView.__repr__
DA-344 Apr 19, 2025
8376dbf
chore: Add Thumbnail.description char limit to docs
DA-344 Apr 20, 2025
9f3f8f1
chore: Add MediaGalleryItem.description char limit to docs
DA-344 Apr 20, 2025
e0c0753
chore: Update interactions docs
DA-344 Apr 20, 2025
2248df0
chore: Add char limit to TextDisplay
DA-344 Apr 20, 2025
22e4738
chore: Fix interaction_check not being called correctly
DA-344 Apr 20, 2025
92cb557
chore: Remove leftover code
DA-344 Apr 20, 2025
876397e
chore: Improve Items documentation
DA-344 Apr 22, 2025
4cb3b41
chore: more docs things ig
DA-344 Apr 22, 2025
f5ec966
chore: typings and docs and idk what more
DA-344 Apr 22, 2025
0dbd465
fix: g
DA-344 Apr 22, 2025
af952d3
chore: add LayoutView example
DA-344 Apr 22, 2025
f5415f5
chore: remove deprecation warning
DA-344 Apr 23, 2025
952a623
remove unused import
DA-344 Apr 23, 2025
c5d7450
fix: strange error: https://discord.com/channels/336642139381301249/1…
DA-344 Apr 23, 2025
01d3bb2
Merge branch 'feat/components-v2' of https://github.com/DA-344/d.py i…
DA-344 Apr 23, 2025
dbd8cd6
chore: update container and things
DA-344 Apr 23, 2025
7ed69ec
chore: children, * -> *children
DA-344 Apr 23, 2025
95a22ce
.
DA-344 Apr 24, 2025
776d5e1
unpack
DA-344 Apr 24, 2025
038ca4a
more unpack
DA-344 Apr 24, 2025
ab49798
chore: Update examples and things
DA-344 Apr 25, 2025
5a1afb6
chore: Update message.component doc types
DA-344 Apr 25, 2025
de4d8c4
fix: LayoutView’s duplicating items
DA-344 Apr 26, 2025
5162d17
fix typings and errors
DA-344 Apr 26, 2025
a8285e1
more typings
DA-344 Apr 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
T = TypeVar('T', bound=VoiceProtocol)

if TYPE_CHECKING:
from typing_extensions import Self

Check warning on line 76 in discord/abc.py

View workflow job for this annotation

GitHub Actions / check 3.x

Import "typing_extensions" could not be resolved from source (reportMissingModuleSource)

from .client import Client
from .user import ClientUser
Expand All @@ -95,7 +95,7 @@
)
from .poll import Poll
from .threads import Thread
from .ui.view import View
from .ui.view import BaseView
from .types.channel import (
PermissionOverwrite as PermissionOverwritePayload,
Channel as ChannelPayload,
Expand Down Expand Up @@ -1388,7 +1388,7 @@
allowed_mentions: AllowedMentions = ...,
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: View = ...,
view: BaseView = ...,
suppress_embeds: bool = ...,
silent: bool = ...,
poll: Poll = ...,
Expand All @@ -1409,7 +1409,7 @@
allowed_mentions: AllowedMentions = ...,
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: View = ...,
view: BaseView = ...,
suppress_embeds: bool = ...,
silent: bool = ...,
poll: Poll = ...,
Expand All @@ -1430,7 +1430,7 @@
allowed_mentions: AllowedMentions = ...,
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: View = ...,
view: BaseView = ...,
suppress_embeds: bool = ...,
silent: bool = ...,
poll: Poll = ...,
Expand All @@ -1451,7 +1451,7 @@
allowed_mentions: AllowedMentions = ...,
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: View = ...,
view: BaseView = ...,
suppress_embeds: bool = ...,
silent: bool = ...,
poll: Poll = ...,
Expand All @@ -1473,7 +1473,7 @@
allowed_mentions: Optional[AllowedMentions] = None,
reference: Optional[Union[Message, MessageReference, PartialMessage]] = None,
mention_author: Optional[bool] = None,
view: Optional[View] = None,
view: Optional[BaseView] = None,
suppress_embeds: bool = False,
silent: bool = False,
poll: Optional[Poll] = None,
Expand Down Expand Up @@ -1546,10 +1546,12 @@
If set, overrides the :attr:`~discord.AllowedMentions.replied_user` attribute of ``allowed_mentions``.

.. versionadded:: 1.6
view: :class:`discord.ui.View`
view: Union[:class:`discord.ui.View`, :class:`discord.ui.LayoutView`]
A Discord UI View to add to the message.

.. versionadded:: 2.0
.. versionchanged:: 2.6
This parameter now accepts :class:`discord.ui.LayoutView` instances.
stickers: Sequence[Union[:class:`~discord.GuildSticker`, :class:`~discord.StickerItem`]]
A list of stickers to upload. Must be a maximum of 3.

Expand Down
9 changes: 6 additions & 3 deletions discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
)

if TYPE_CHECKING:
from typing_extensions import Self

Check warning on line 88 in discord/channel.py

View workflow job for this annotation

GitHub Actions / check 3.x

Import "typing_extensions" could not be resolved from source (reportMissingModuleSource)

from .types.threads import ThreadArchiveDuration
from .role import Role
Expand All @@ -100,7 +100,7 @@
from .file import File
from .user import ClientUser, User, BaseUser
from .guild import Guild, GuildChannel as GuildChannelType
from .ui.view import View
from .ui.view import BaseView
from .types.channel import (
TextChannel as TextChannelPayload,
NewsChannel as NewsChannelPayload,
Expand Down Expand Up @@ -2857,7 +2857,7 @@
allowed_mentions: AllowedMentions = MISSING,
mention_author: bool = MISSING,
applied_tags: Sequence[ForumTag] = MISSING,
view: View = MISSING,
view: BaseView = MISSING,
suppress_embeds: bool = False,
reason: Optional[str] = None,
) -> ThreadWithMessage:
Expand Down Expand Up @@ -2907,8 +2907,11 @@
If set, overrides the :attr:`~discord.AllowedMentions.replied_user` attribute of ``allowed_mentions``.
applied_tags: List[:class:`discord.ForumTag`]
A list of tags to apply to the thread.
view: :class:`discord.ui.View`
view: Union[:class:`discord.ui.View`, :class:`discord.ui.LayoutView`]
A Discord UI View to add to the message.

.. versionchanged:: 2.6
This parameter now accepts :class:`discord.ui.LayoutView` instances.
stickers: Sequence[Union[:class:`~discord.GuildSticker`, :class:`~discord.StickerItem`]]
A list of stickers to upload. Must be a maximum of 3.
suppress_embeds: :class:`bool`
Expand Down
15 changes: 9 additions & 6 deletions discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
from .backoff import ExponentialBackoff
from .webhook import Webhook
from .appinfo import AppInfo
from .ui.view import View
from .ui.view import BaseView
from .ui.dynamic import DynamicItem
from .stage_instance import StageInstance
from .threads import Thread
Expand All @@ -82,7 +82,7 @@
if TYPE_CHECKING:
from types import TracebackType

from typing_extensions import Self

Check warning on line 85 in discord/client.py

View workflow job for this annotation

GitHub Actions / check 3.x

Import "typing_extensions" could not be resolved from source (reportMissingModuleSource)

from .abc import Messageable, PrivateChannel, Snowflake, SnowflakeTime
from .app_commands import Command, ContextMenu
Expand Down Expand Up @@ -3149,7 +3149,7 @@

self._connection.remove_dynamic_items(*items)

def add_view(self, view: View, *, message_id: Optional[int] = None) -> None:
def add_view(self, view: BaseView, *, message_id: Optional[int] = None) -> None:
"""Registers a :class:`~discord.ui.View` for persistent listening.

This method should be used for when a view is comprised of components
Expand All @@ -3159,8 +3159,11 @@

Parameters
------------
view: :class:`discord.ui.View`
view: Union[:class:`discord.ui.View`, :class:`discord.ui.LayoutView`]
The view to register for dispatching.

.. versionchanged:: 2.6
This now accepts :class:`discord.ui.LayoutView` instances.
message_id: Optional[:class:`int`]
The message ID that the view is attached to. This is currently used to
refresh the view's state during message update events. If not given
Expand All @@ -3175,7 +3178,7 @@
and all their components have an explicitly provided custom_id.
"""

if not isinstance(view, View):
if not isinstance(view, BaseView):
raise TypeError(f'expected an instance of View not {view.__class__.__name__}')

if not view.is_persistent():
Expand All @@ -3187,8 +3190,8 @@
self._connection.store_view(view, message_id)

@property
def persistent_views(self) -> Sequence[View]:
"""Sequence[:class:`.View`]: A sequence of persistent views added to the client.
def persistent_views(self) -> Sequence[BaseView]:
"""Sequence[Union[:class:`.View`, :class:`.LayoutView`]]: A sequence of persistent views added to the client.

.. versionadded:: 2.0
"""
Expand Down
Loading
Loading