Skip to content
Open
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
2fcd3a9
downgrade view
NeloBlivion Sep 3, 2025
027527d
Merge branch 'master' into cv2_fixes
NeloBlivion Sep 3, 2025
b319d13
skeleton for actionrow
NeloBlivion Sep 3, 2025
fcb0849
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 3, 2025
d1f33ea
cleanup
NeloBlivion Sep 3, 2025
8efedd3
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 3, 2025
54afda3
Merge branch 'master' into cv2_fixes
Lulalaby Sep 3, 2025
6d6ce3e
eh..... going through it... don't judge yet................
NeloBlivion Sep 3, 2025
f13f5e0
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 3, 2025
b322b42
correct
NeloBlivion Sep 3, 2025
c0022f1
v2
NeloBlivion Sep 3, 2025
e830df4
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 3, 2025
be236bf
Merge branch 'master' into cv2_fixes
NeloBlivion Sep 22, 2025
23f296d
better separation of views
NeloBlivion Sep 22, 2025
57a0d98
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2025
eaa2c30
import
NeloBlivion Sep 22, 2025
c6c4fbf
)
NeloBlivion Sep 22, 2025
57282b8
))
NeloBlivion Sep 22, 2025
1da73f6
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2025
2b981d3
attempt modal conversion
NeloBlivion Sep 22, 2025
c929c67
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2025
e61064d
types
NeloBlivion Sep 22, 2025
d8e3d4f
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2025
057a26b
container uses actionrow instead of button/select, remove decorator s…
NeloBlivion Sep 22, 2025
b7a8f6b
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2025
166f540
types
NeloBlivion Sep 22, 2025
a7346cd
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2025
836998d
imports
NeloBlivion Sep 22, 2025
16b4886
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2025
5255da1
remove Select.label & Select.description
NeloBlivion Sep 22, 2025
a1068fb
update refresh logic
NeloBlivion Sep 22, 2025
e199c8c
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2025
0dc7522
typext
NeloBlivion Sep 22, 2025
bfd4aed
reduce further
NeloBlivion Sep 22, 2025
1223dea
fix __all__
NeloBlivion Sep 22, 2025
3a82843
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2025
25fbd2a
typecheck
NeloBlivion Sep 22, 2025
3ee00e0
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2025
61a1433
__
NeloBlivion Sep 22, 2025
edb4951
dispatch
NeloBlivion Sep 22, 2025
d9c465b
ComponentType
NeloBlivion Sep 22, 2025
1ae1c77
types ?
NeloBlivion Sep 22, 2025
bd60e9b
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2025
090af2e
typecheck again
NeloBlivion Sep 22, 2025
00faca4
attrs
NeloBlivion Sep 22, 2025
5c7a02b
fixes
NeloBlivion Sep 22, 2025
1975f6d
adjust
NeloBlivion Sep 22, 2025
2816b1b
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2025
e615190
actionrow components
NeloBlivion Sep 22, 2025
93fb09a
arc
NeloBlivion Sep 22, 2025
0517d2e
button priority
NeloBlivion Sep 22, 2025
e32fdad
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2025
bdb6d21
maybe?
NeloBlivion Sep 22, 2025
20aae0f
no
NeloBlivion Sep 22, 2025
a846b43
update examples
NeloBlivion Sep 23, 2025
7caf4f5
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 23, 2025
0060e0f
remove v2 from weights
NeloBlivion Sep 23, 2025
8308615
misc
NeloBlivion Sep 23, 2025
5410e00
adjust Label args (first arg label)
NeloBlivion Sep 23, 2025
d4dc1c5
add select overloads
NeloBlivion Sep 23, 2025
b619025
actionrow clarification
NeloBlivion Sep 23, 2025
f90a3bc
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 23, 2025
35e4cb1
all items in actionrow have the disabled attribute
NeloBlivion Sep 23, 2025
65a1116
fixes
NeloBlivion Sep 24, 2025
e453e01
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 24, 2025
e9ac8bc
more imports
NeloBlivion Sep 25, 2025
b2ed0d1
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 25, 2025
9ca373a
docs and typing cleanup
NeloBlivion Sep 25, 2025
0acb103
update _component_to_item
NeloBlivion Sep 26, 2025
43df60f
fix to_component_dict
NeloBlivion Oct 3, 2025
0b58904
attempt splitting into ViewItem and ModalItem
NeloBlivion Oct 3, 2025
3a8bb10
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 3, 2025
64f3c4f
more
NeloBlivion Oct 3, 2025
45a5c44
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 3, 2025
4ee4b70
guys don't you love typing changes
NeloBlivion Oct 3, 2025
fd67ea2
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 3, 2025
148535a
types
NeloBlivion Oct 3, 2025
bcc1a7a
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 3, 2025
712cd3c
this is required apparently
NeloBlivion Oct 3, 2025
ef78980
self.modal
NeloBlivion Oct 3, 2025
9cf2886
set modal
NeloBlivion Oct 3, 2025
62ffcdf
no weights in basemodal
NeloBlivion Oct 3, 2025
a961d49
undo on_modal_error change
NeloBlivion Oct 3, 2025
8664272
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 3, 2025
fbac652
define Item.type
NeloBlivion Oct 3, 2025
c2bd6b5
further consolidate
NeloBlivion Oct 3, 2025
9255c39
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 3, 2025
8fdc3f1
oops
NeloBlivion Oct 3, 2025
8a9fe8f
fix modal init
NeloBlivion Oct 3, 2025
38352c2
actual fix
NeloBlivion Oct 3, 2025
1d790da
forgot modal children thing
NeloBlivion Oct 3, 2025
846b14d
clarify
NeloBlivion Oct 3, 2025
157d8c7
adjust item docs
NeloBlivion Oct 4, 2025
fb01cfe
copyright
NeloBlivion Oct 5, 2025
340b5d5
children
NeloBlivion Oct 5, 2025
3f3ae31
Update discord/ui/action_row.py
NeloBlivion Oct 6, 2025
be9eb51
add Webhook.parent
NeloBlivion Oct 6, 2025
cf49aa3
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 6, 2025
017f15f
add Webhook.from_interaction
NeloBlivion Oct 6, 2025
bba29af
slots
NeloBlivion Oct 6, 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
14 changes: 7 additions & 7 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
from .types.channel import GuildChannel as GuildChannelPayload
from .types.channel import OverwriteType
from .types.channel import PermissionOverwrite as PermissionOverwritePayload
from .ui.view import View
from .ui.view import BaseView
from .user import ClientUser

PartialMessageableChannel = Union[
Expand Down Expand Up @@ -1355,7 +1355,7 @@ async def send(
allowed_mentions: AllowedMentions = ...,
reference: Message | MessageReference | PartialMessage = ...,
mention_author: bool = ...,
view: View = ...,
view: BaseView = ...,
poll: Poll = ...,
suppress: bool = ...,
silent: bool = ...,
Expand All @@ -1376,7 +1376,7 @@ async def send(
allowed_mentions: AllowedMentions = ...,
reference: Message | MessageReference | PartialMessage = ...,
mention_author: bool = ...,
view: View = ...,
view: BaseView = ...,
poll: Poll = ...,
suppress: bool = ...,
silent: bool = ...,
Expand All @@ -1397,7 +1397,7 @@ async def send(
allowed_mentions: AllowedMentions = ...,
reference: Message | MessageReference | PartialMessage = ...,
mention_author: bool = ...,
view: View = ...,
view: BaseView = ...,
poll: Poll = ...,
suppress: bool = ...,
silent: bool = ...,
Expand All @@ -1418,7 +1418,7 @@ async def send(
allowed_mentions: AllowedMentions = ...,
reference: Message | MessageReference | PartialMessage = ...,
mention_author: bool = ...,
view: View = ...,
view: BaseView = ...,
Copy link
Contributor

Choose a reason for hiding this comment

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

No overloads for DesignerView and no content, embeds etc?

Same thing for all the other send methods.

Copy link
Member Author

Choose a reason for hiding this comment

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

i probably should but god it's a pain

poll: Poll = ...,
suppress: bool = ...,
silent: bool = ...,
Expand Down Expand Up @@ -1509,7 +1509,7 @@ async def send(
If set, overrides the :attr:`~discord.AllowedMentions.replied_user` attribute of ``allowed_mentions``.

.. versionadded:: 1.6
view: :class:`discord.ui.View`
view: :class:`discord.ui.BaseView`
A Discord UI View to add to the message.
embeds: List[:class:`~discord.Embed`]
A list of embeds to upload. Must be a maximum of 10.
Expand Down Expand Up @@ -1611,7 +1611,7 @@ async def send(
if view:
if not hasattr(view, "__discord_ui_view__"):
raise InvalidArgument(
f"view parameter must be View not {view.__class__!r}"
f"view parameter must be BaseView not {view.__class__!r}"
)

components = view.to_components()
Expand Down
8 changes: 4 additions & 4 deletions discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
from .types.channel import VoiceChannelEffectSendEvent as VoiceChannelEffectSend
from .types.snowflake import SnowflakeList
from .types.threads import ThreadArchiveDuration
from .ui.view import View
from .ui.view import BaseView
from .user import BaseUser, ClientUser, User
from .webhook import Webhook

Expand Down Expand Up @@ -1217,7 +1217,7 @@ async def create_thread(
delete_message_after: float | None = None,
nonce: int | str | None = None,
allowed_mentions: AllowedMentions | None = None,
view: View | None = None,
view: BaseView | None = None,
applied_tags: list[ForumTag] | None = None,
suppress: bool = False,
silent: bool = False,
Expand Down Expand Up @@ -1262,7 +1262,7 @@ async def create_thread(
to the object, otherwise it uses the attributes set in :attr:`~discord.Client.allowed_mentions`.
If no object is passed at all then the defaults given by :attr:`~discord.Client.allowed_mentions`
are used instead.
view: :class:`discord.ui.View`
view: :class:`discord.ui.BaseView`
A Discord UI View to add to the message.
applied_tags: List[:class:`discord.ForumTag`]
A list of tags to apply to the new thread.
Expand Down Expand Up @@ -1328,7 +1328,7 @@ async def create_thread(
if view:
if not hasattr(view, "__discord_ui_view__"):
raise InvalidArgument(
f"view parameter must be View not {view.__class__!r}"
f"view parameter must be BaseView not {view.__class__!r}"
)

components = view.to_components()
Expand Down
22 changes: 11 additions & 11 deletions discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
from .sticker import GuildSticker, StandardSticker, StickerPack, _sticker_factory
from .template import Template
from .threads import Thread
from .ui.view import View
from .ui.view import BaseView
from .user import ClientUser, User
from .utils import MISSING
from .voice_client import VoiceClient
Expand All @@ -74,7 +74,7 @@
from .message import Message
from .poll import Poll
from .soundboard import SoundboardSound
from .ui.item import Item
from .ui.item import Item, ViewItem
from .voice_client import VoiceProtocol

__all__ = ("Client",)
Expand Down Expand Up @@ -546,19 +546,19 @@ async def on_error(self, event_method: str, *args: Any, **kwargs: Any) -> None:
traceback.print_exc()

async def on_view_error(
self, error: Exception, item: Item, interaction: Interaction
self, error: Exception, item: ViewItem, interaction: Interaction
) -> None:
"""|coro|

The default view error handler provided by the client.

This only fires for a view if you did not define its :func:`~discord.ui.View.on_error`.
This only fires for a view if you did not define its :func:`~discord.ui.BaseView.on_error`.

Parameters
----------
error: :class:`Exception`
The exception that was raised.
item: :class:`Item`
item: :class:`ViewItem`
The item that the user interacted with.
interaction: :class:`Interaction`
The interaction that was received.
Expand Down Expand Up @@ -2037,8 +2037,8 @@ async def create_dm(self, user: Snowflake) -> DMChannel:
data = await state.http.start_private_message(user.id)
return state.add_dm_channel(data)

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

This method should be used for when a view is comprised of components
that last longer than the lifecycle of the program.
Expand All @@ -2047,7 +2047,7 @@ def add_view(self, view: View, *, message_id: int | None = None) -> None:

Parameters
----------
view: :class:`discord.ui.View`
view: :class:`discord.ui.BaseView`
The view to register for dispatching.
message_id: Optional[:class:`int`]
The message ID that the view is attached to. This is currently used to
Expand All @@ -2063,8 +2063,8 @@ def add_view(self, view: View, *, message_id: int | None = None) -> None:
and all their components have an explicitly provided ``custom_id``.
"""

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

if not view.is_persistent():
raise ValueError(
Expand All @@ -2075,7 +2075,7 @@ def add_view(self, view: View, *, message_id: int | None = None) -> None:
self._connection.store_view(view, message_id)

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

.. versionadded:: 2.0
Expand Down
14 changes: 10 additions & 4 deletions discord/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def __init__(self, data: ComponentPayload):

@property
def width(self):
"""Return the sum of the children's widths."""
"""Return the sum of the items' widths."""
t = 0
for item in self.children:
t += 1 if item.type is ComponentType.button else 5
Expand All @@ -192,6 +192,10 @@ def to_dict(self) -> ActionRowPayload:
def walk_components(self) -> Iterator[Component]:
yield from self.children

@property
def components(self) -> list[Component]:
return self.children

def get_component(self, id: str | int) -> Component | None:
"""Get a component from this action row. Roughly equivalent to `utils.get(row.children, ...)`.
If an ``int`` is provided, the component will be retrieved by ``id``, otherwise by ``custom_id``.
Expand Down Expand Up @@ -266,7 +270,7 @@ def __init__(self, data: InputTextComponentPayload):
self.id: int | None = data.get("id")
self.style: InputTextStyle = try_enum(InputTextStyle, data["style"])
self.custom_id = data["custom_id"]
self.label: str = data.get("label", None)
self.label: str | None = data.get("label", None)
self.placeholder: str | None = data.get("placeholder", None)
self.min_length: int | None = data.get("min_length", None)
self.max_length: int | None = data.get("max_length", None)
Expand All @@ -278,7 +282,6 @@ def to_dict(self) -> InputTextComponentPayload:
"type": 4,
"id": self.id,
"style": self.style.value,
"label": self.label,
}
if self.custom_id:
payload["custom_id"] = self.custom_id
Expand All @@ -298,6 +301,9 @@ def to_dict(self) -> InputTextComponentPayload:
if self.value:
payload["value"] = self.value

if self.label:
payload["label"] = self.label

return payload # type: ignore


Expand Down Expand Up @@ -1305,7 +1311,7 @@ class Label(Component):
``component`` may only be:

- :class:`InputText`
- :class:`SelectMenu` (string)
- :class:`SelectMenu`

This inherits from :class:`Component`.

Expand Down
1 change: 1 addition & 0 deletions discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ class ComponentType(Enum):
separator = 14
content_inventory_entry = 16
container = 17
label = 18

def __int__(self):
return self.value
Expand Down
22 changes: 11 additions & 11 deletions discord/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
from .types.interactions import InteractionMetadata as InteractionMetadataPayload
from .types.interactions import MessageInteraction as MessageInteractionPayload
from .ui.modal import Modal
from .ui.view import View
from .ui.view import BaseView

InteractionChannel = Union[
VoiceChannel,
Expand Down Expand Up @@ -164,7 +164,7 @@ class Interaction:
The command that this interaction belongs to.

.. versionadded:: 2.7
view: Optional[:class:`View`]
view: Optional[:class:`BaseView`]
The view that this interaction belongs to.

.. versionadded:: 2.7
Expand Down Expand Up @@ -257,7 +257,7 @@ def _from_data(self, data: InteractionPayload):
)

self.command: ApplicationCommand | None = None
self.view: View | None = None
self.view: BaseView | None = None
self.modal: Modal | None = None
self.attachment_size_limit: int = data.get("attachment_size_limit")

Expand Down Expand Up @@ -522,7 +522,7 @@ async def edit_original_response(
file: File = MISSING,
files: list[File] = MISSING,
attachments: list[Attachment] = MISSING,
view: View | None = MISSING,
view: BaseView | None = MISSING,
allowed_mentions: AllowedMentions | None = None,
delete_after: float | None = None,
suppress: bool = False,
Expand Down Expand Up @@ -557,7 +557,7 @@ async def edit_original_response(
allowed_mentions: :class:`AllowedMentions`
Controls the mentions being processed in this message.
See :meth:`.abc.Messageable.send` for more information.
view: Optional[:class:`~discord.ui.View`]
view: Optional[:class:`~discord.ui.BaseView`]
The updated view to update this message with. If ``None`` is passed then
the view is removed.
delete_after: Optional[:class:`float`]
Expand Down Expand Up @@ -947,7 +947,7 @@ async def send_message(
*,
embed: Embed = None,
embeds: list[Embed] = None,
view: View = None,
view: BaseView = None,
tts: bool = False,
ephemeral: bool = False,
allowed_mentions: AllowedMentions = None,
Expand All @@ -972,7 +972,7 @@ async def send_message(
``embeds`` parameter.
tts: :class:`bool`
Indicates if the message should be sent using text-to-speech.
view: :class:`discord.ui.View`
view: :class:`discord.ui.BaseView`
The view to send with the message.
ephemeral: :class:`bool`
Indicates if the message should only be visible to the user who started the interaction.
Expand Down Expand Up @@ -1128,7 +1128,7 @@ async def edit_message(
file: File = MISSING,
files: list[File] = MISSING,
attachments: list[Attachment] = MISSING,
view: View | None = MISSING,
view: BaseView | None = MISSING,
delete_after: float | None = None,
suppress: bool | None = MISSING,
allowed_mentions: AllowedMentions | None = None,
Expand All @@ -1155,7 +1155,7 @@ async def edit_message(
attachments: List[:class:`Attachment`]
A list of attachments to keep in the message. If ``[]`` is passed
then all attachments are removed.
view: Optional[:class:`~discord.ui.View`]
view: Optional[:class:`~discord.ui.BaseView`]
The updated view to update this message with. If ``None`` is passed then
the view is removed.
delete_after: Optional[:class:`float`]
Expand Down Expand Up @@ -1486,7 +1486,7 @@ async def edit(
file: File = MISSING,
files: list[File] = MISSING,
attachments: list[Attachment] = MISSING,
view: View | None = MISSING,
view: BaseView | None = MISSING,
allowed_mentions: AllowedMentions | None = None,
delete_after: float | None = None,
suppress: bool | None = MISSING,
Expand Down Expand Up @@ -1515,7 +1515,7 @@ async def edit(
allowed_mentions: :class:`AllowedMentions`
Controls the mentions being processed in this message.
See :meth:`.abc.Messageable.send` for more information.
view: Optional[:class:`~discord.ui.View`]
view: Optional[:class:`~discord.ui.BaseView`]
The updated view to update this message with. If ``None`` is passed then
the view is removed.
delete_after: Optional[:class:`float`]
Expand Down
10 changes: 5 additions & 5 deletions discord/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
from .types.snowflake import SnowflakeList
from .types.threads import ThreadArchiveDuration
from .types.user import User as UserPayload
from .ui.view import View
from .ui.view import BaseView
from .user import User

MR = TypeVar("MR", bound="MessageReference")
Expand Down Expand Up @@ -1660,7 +1660,7 @@ async def edit(
suppress: bool = ...,
delete_after: float | None = ...,
allowed_mentions: AllowedMentions | None = ...,
view: View | None = ...,
view: BaseView | None = ...,
) -> Message: ...

async def edit(
Expand All @@ -1674,7 +1674,7 @@ async def edit(
suppress: bool = MISSING,
delete_after: float | None = None,
allowed_mentions: AllowedMentions | None = MISSING,
view: View | None = MISSING,
view: BaseView | None = MISSING,
) -> Message:
"""|coro|

Expand Down Expand Up @@ -1723,7 +1723,7 @@ async def edit(
are used instead.

.. versionadded:: 1.4
view: Optional[:class:`~discord.ui.View`]
view: Optional[:class:`~discord.ui.BaseView`]
The updated view to update this message with. If ``None`` is passed then
the view is removed.

Expand Down Expand Up @@ -2412,7 +2412,7 @@ async def edit(self, **fields: Any) -> Message | None:
to the object, otherwise it uses the attributes set in :attr:`~discord.Client.allowed_mentions`.
If no object is passed at all then the defaults given by :attr:`~discord.Client.allowed_mentions`
are used instead.
view: Optional[:class:`~discord.ui.View`]
view: Optional[:class:`~discord.ui.BaseView`]
The updated view to update this message with. If ``None`` is passed then
the view is removed.

Expand Down
Loading