Skip to content

feat: components v2 #1294

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

Draft
wants to merge 40 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a7cf032
feat(flags): add new message flag
shiftinv Jan 9, 2025
9becf08
feat(enums): add new component types
shiftinv Jan 9, 2025
215f37f
feat(types): add `id` field to all component types
shiftinv Jan 9, 2025
91325ed
feat(types): add typeddicts for new components
shiftinv Jan 9, 2025
c5084d8
chore: add some comments from testing
shiftinv Jan 9, 2025
cf74701
fix: thumbnail media field has been renamed now
shiftinv Jan 25, 2025
bd96624
chore: update comment now that sections allow buttons too
shiftinv Feb 4, 2025
e06c077
fix: make `SectionComponent.components` typing more permissive
shiftinv Feb 20, 2025
f2f2817
feat: add `SeparatorSpacingSize` enum
shiftinv Feb 20, 2025
93902f5
feat(components): implement new component classes roughly
shiftinv Feb 20, 2025
7765c46
fix(components): rename `components.File` -> `components.FileComponen…
shiftinv Feb 20, 2025
0222377
feat: add new components to factory function
shiftinv Feb 20, 2025
9bb4013
fix: improve `Container` repr
shiftinv Feb 20, 2025
928033c
refactor: rename existing action row component type aliases
shiftinv Feb 21, 2025
b37c87c
perf: use mapping for `_component_factory`
shiftinv Feb 21, 2025
ff6c20d
refactor: make child component typehints more specific
shiftinv Feb 21, 2025
2522af4
chore: move some TODOs
shiftinv Feb 21, 2025
103c1c2
docs: add docstrings for new components
shiftinv Feb 21, 2025
a363451
feat(types): make child component types for `ActionRow` and `SectionC…
shiftinv Feb 21, 2025
3cfcdd0
fix(typing): resolve pyright complaints related to `Message.components`
shiftinv Feb 21, 2025
7cd06f0
refactor(typing): expand `Message.components` type beyond just `Actio…
shiftinv Feb 21, 2025
82eb456
fix: update relevant methods to account for new `Message.components` …
shiftinv Feb 22, 2025
a7c2648
feat: add `id` field to message/modal interaction data
shiftinv Mar 6, 2025
891ca40
refactor: introduce yet another ui base type, for non-actionrow-child…
shiftinv Mar 8, 2025
bd2865a
feat(ui): add new ui components, still partially broken
shiftinv Mar 15, 2025
222f513
refactor(ui): rework section and container to actually be usable
shiftinv Mar 15, 2025
962c5d7
docs: add ui components to docs, fix references
shiftinv Mar 15, 2025
a95e1b2
fix(ui): fix `MediaGallery` parameter type
shiftinv Mar 15, 2025
6198aa6
refactor(types): move action row types to `ui._types`, add some short…
shiftinv Mar 15, 2025
0ded39d
feat(types): add new components to `MessageComponentInput` union
shiftinv Mar 15, 2025
2ad9e10
feat: support v2 components in `normalize_components`/`components_to_…
shiftinv Apr 18, 2025
58b6045
docs: add changelog entry
shiftinv Apr 18, 2025
69591bf
fix: make `ActionRow` subclass `UIComponent`
shiftinv Jun 9, 2025
a8fb923
chore: rename `(Message|Modal)ComponentInput` utility type to `(Messa…
shiftinv Jun 9, 2025
95ac094
chore(typing): declare `__repr_attributes__` in components as classvars
shiftinv Jun 9, 2025
3dd1aa7
chore: clarify name of action row child type tuple
shiftinv Jun 9, 2025
61cb394
refactor: try/catch component_factory
shiftinv Jun 9, 2025
567a685
fix(types): `typing.TypeAlias` is 3.10+
shiftinv Jun 9, 2025
23ac2e1
perf: reduce `_message_component_factory` call overhead
shiftinv Jun 11, 2025
7bee2ce
fix: support reused components in `_walk_all_components`
shiftinv Jun 11, 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
1 change: 1 addition & 0 deletions changelog/1294.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO.
20 changes: 10 additions & 10 deletions disnake/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
PermissionOverwrite as PermissionOverwritePayload,
)
from .types.threads import PartialForumTag as PartialForumTagPayload
from .ui.action_row import Components, MessageUIComponent
from .ui._types import MessageComponents
from .ui.view import View
from .user import ClientUser
from .voice_region import VoiceRegion
Expand Down Expand Up @@ -1433,7 +1433,7 @@ async def send(
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: View = ...,
components: Components[MessageUIComponent] = ...,
components: MessageComponents = ...,
poll: Poll = ...,
) -> Message: ...

Expand All @@ -1454,7 +1454,7 @@ async def send(
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: View = ...,
components: Components[MessageUIComponent] = ...,
components: MessageComponents = ...,
poll: Poll = ...,
) -> Message: ...

Expand All @@ -1475,7 +1475,7 @@ async def send(
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: View = ...,
components: Components[MessageUIComponent] = ...,
components: MessageComponents = ...,
poll: Poll = ...,
) -> Message: ...

Expand All @@ -1496,7 +1496,7 @@ async def send(
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: View = ...,
components: Components[MessageUIComponent] = ...,
components: MessageComponents = ...,
poll: Poll = ...,
) -> Message: ...

Expand All @@ -1518,7 +1518,7 @@ async def send(
reference: Optional[Union[Message, MessageReference, PartialMessage]] = None,
mention_author: Optional[bool] = None,
view: Optional[View] = None,
components: Optional[Components[MessageUIComponent]] = None,
components: Optional[MessageComponents] = None,
poll: Optional[Poll] = None,
):
"""|coro|
Expand All @@ -1531,8 +1531,8 @@ async def send(
``stickers``, ``components``, ``poll`` or ``view`` must be provided.

To upload a single file, the ``file`` parameter should be used with a
single :class:`.File` object. To upload multiple files, the ``files``
parameter should be used with a :class:`list` of :class:`.File` objects.
single :class:`~disnake.File` object. To upload multiple files, the ``files``
parameter should be used with a :class:`list` of :class:`~disnake.File` objects.
**Specifying both parameters will lead to an exception**.

To upload a single embed, the ``embed`` parameter should be used with a
Expand All @@ -1558,9 +1558,9 @@ async def send(

.. versionadded:: 2.0

file: :class:`.File`
file: :class:`~disnake.File`
The file to upload. This cannot be mixed with the ``files`` parameter.
files: List[:class:`.File`]
files: List[:class:`~disnake.File`]
A list of files to upload. Must be a maximum of 10.
This cannot be mixed with the ``file`` parameter.
stickers: Sequence[Union[:class:`.GuildSticker`, :class:`.StandardSticker`, :class:`.StickerItem`]]
Expand Down
16 changes: 8 additions & 8 deletions disnake/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
from .types.soundboard import PartialSoundboardSound as PartialSoundboardSoundPayload
from .types.threads import ThreadArchiveDurationLiteral
from .types.voice import VoiceChannelEffect as VoiceChannelEffectPayload
from .ui.action_row import Components, MessageUIComponent
from .ui._types import MessageComponents
from .ui.view import View
from .user import BaseUser, ClientUser, User
from .voice_region import VoiceRegion
Expand Down Expand Up @@ -3484,7 +3484,7 @@ async def create_thread(
stickers: Sequence[Union[GuildSticker, StandardSticker, StickerItem]] = ...,
allowed_mentions: AllowedMentions = ...,
view: View = ...,
components: Components = ...,
components: MessageComponents = ...,
reason: Optional[str] = None,
) -> ThreadWithMessage: ...

Expand All @@ -3504,7 +3504,7 @@ async def create_thread(
stickers: Sequence[Union[GuildSticker, StandardSticker, StickerItem]] = ...,
allowed_mentions: AllowedMentions = ...,
view: View = ...,
components: Components = ...,
components: MessageComponents = ...,
reason: Optional[str] = None,
) -> ThreadWithMessage: ...

Expand All @@ -3524,7 +3524,7 @@ async def create_thread(
stickers: Sequence[Union[GuildSticker, StandardSticker, StickerItem]] = ...,
allowed_mentions: AllowedMentions = ...,
view: View = ...,
components: Components = ...,
components: MessageComponents = ...,
reason: Optional[str] = None,
) -> ThreadWithMessage: ...

Expand All @@ -3544,7 +3544,7 @@ async def create_thread(
stickers: Sequence[Union[GuildSticker, StandardSticker, StickerItem]] = ...,
allowed_mentions: AllowedMentions = ...,
view: View = ...,
components: Components = ...,
components: MessageComponents = ...,
reason: Optional[str] = None,
) -> ThreadWithMessage: ...

Expand All @@ -3565,7 +3565,7 @@ async def create_thread(
stickers: Sequence[Union[GuildSticker, StandardSticker, StickerItem]] = MISSING,
allowed_mentions: AllowedMentions = MISSING,
view: View = MISSING,
components: Components[MessageUIComponent] = MISSING,
components: MessageComponents = MISSING,
reason: Optional[str] = None,
) -> ThreadWithMessage:
"""|coro|
Expand Down Expand Up @@ -3625,9 +3625,9 @@ async def create_thread(

.. versionadded:: 2.9

file: :class:`.File`
file: :class:`~disnake.File`
The file to upload. This cannot be mixed with the ``files`` parameter.
files: List[:class:`.File`]
files: List[:class:`~disnake.File`]
A list of files to upload. Must be a maximum of 10.
This cannot be mixed with the ``file`` parameter.
stickers: Sequence[Union[:class:`.GuildSticker`, :class:`.StandardSticker`, :class:`.StickerItem`]]
Expand Down
Loading
Loading