Skip to content
Merged
Show file tree
Hide file tree
Changes from 238 commits
Commits
Show all changes
286 commits
Select commit Hold shift + click to select a range
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
aa41094
fix: Non-dispatchable items breaking persistent views
DA-344 Apr 29, 2025
7741166
chore: Add (View|Container|ActionRow|Section).walk_children methods
DA-344 Apr 29, 2025
0621b38
chore: Update overloads typings
DA-344 Apr 29, 2025
2da3a14
chore: Raise LayoutView component limit to 40 and remove component li…
DA-344 Apr 30, 2025
d41d711
list -> tuple
DA-344 Apr 30, 2025
50c40a2
fix: Change send type to None in Section.walk_children return type
DA-344 Apr 30, 2025
b0b332a
fix: Add/Modify View/Container.walk_children return types
DA-344 Apr 30, 2025
9c745bb
chore: run black
DA-344 Apr 30, 2025
4044b2c
chore: add *children param and validation for children
DA-344 Apr 30, 2025
145af2f
chore: update docstrings
DA-344 May 1, 2025
27db09a
chore: overloads
DA-344 May 1, 2025
0396417
rows
DA-344 May 1, 2025
7012cec
fix: LayoutView.__total_children being incorrectly set when adding/re…
DA-344 May 6, 2025
e29c10d
fix: Webhook.send overloads missing ephemeral kwarg
DA-344 May 6, 2025
6122b32
fix: Sorting LayoutView children defaulting to 0 instead of sys.maxsize
DA-344 May 6, 2025
7b5f247
chore: Add call to super().__init_subclass__()
DA-344 May 6, 2025
cf08c0e
chore: Remove ValueError on Container.add_item
DA-344 May 7, 2025
4ca483e
chore: fix is_persistent and default to sys.maxsize instead of 0 on s…
DA-344 May 8, 2025
4103a97
things
DA-344 May 9, 2025
176d0a4
fix attr error things
DA-344 May 12, 2025
8f39bf5
fix: rows being set weirdly because of sorted
DA-344 May 14, 2025
8fc329d
fix: missing applied_tags param on overloads
DA-344 May 14, 2025
0b25cf7
chore: dynamic items
DA-344 May 14, 2025
1281a2e
chore: black
DA-344 May 14, 2025
736fbfc
fix: typings on examples of dynamic
DA-344 May 14, 2025
a19055b
__dispatchable having children that were removed from the Container
DA-344 May 15, 2025
eb38195
fix: Container.__dispatchable not having new dispatchable nested item…
DA-344 May 15, 2025
091705c
chore: remove _ViewWeights leftover code
DA-344 May 15, 2025
eb2996d
Make Container._init_children more similar to BaseView._init_children
DA-344 May 16, 2025
98b6322
if
DA-344 May 16, 2025
4005399
chore: remove setting default row
DA-344 May 16, 2025
2f029c3
fix: Container rows
DA-344 May 16, 2025
acd17d8
chore: Update LayoutView.to_components()
DA-344 May 16, 2025
1b676df
chore: Improve documentation on MediaGallery(Item) and ui.File
DA-344 May 18, 2025
6e302a3
fix: is_persistent returning wrong values
DA-344 May 19, 2025
8e03c3a
fix: is_persistent in container.py
DA-344 May 19, 2025
e329422
feat: Add (Layout)View.from_dict methods
DA-344 May 20, 2025
f63f9f6
chore: Consistency on types
DA-344 May 20, 2025
b221fd2
Merge branch 'feat/components-v2' of https://github.com/DA-344/d.py i…
DA-344 May 20, 2025
22daf24
fix: View.from_dict raising unexpected errors
DA-344 May 20, 2025
b4b7a74
yet more fixes
DA-344 May 20, 2025
5489806
fix: row not being respected when being 0
DA-344 May 20, 2025
c9e0f35
fix: linting
DA-344 May 20, 2025
03af02b
chore: Run black and fix linting errors
DA-344 May 20, 2025
3d37331
chore:
DA-344 May 20, 2025
fe3b596
fix: unexpected behaviour on accent_colours
DA-344 May 20, 2025
cf21c5b
chore: revert double quotes to single quotes
DA-344 May 20, 2025
0a8d9cb
chore: check types on Container.accent_colour setter
DA-344 May 20, 2025
f0c0e40
fix: Colo(u)r being on TYPE_CHECKING block
DA-344 May 21, 2025
d65437b
chore: QoL changes on BaseView.from_message and BaseView.from_dict an…
DA-344 May 27, 2025
3bba5b4
Merge branch 'feat/components-v2' of https://github.com/DA-344/d.py i…
DA-344 May 27, 2025
42bd21a
chore(breaking): Rename SeparatorSize to SeparatorSpacing
DA-344 May 27, 2025
3dfc609
fix: SpacingSpace not being found on docs
DA-344 May 27, 2025
d4e738a
qol things and changes
DA-344 May 28, 2025
ff55d37
changes to every item, mostly on repr
DA-344 May 28, 2025
12abc1a
chore: fix DynamicItem errors
DA-344 May 28, 2025
5bde2f0
chore: rename Section.get_item_by_id to Section.get_item
DA-344 May 28, 2025
d124702
itertools.groupby bye
DA-344 May 28, 2025
78ed233
shuold
DA-344 May 30, 2025
49125e8
chore: update ViewStore.dispatch_view
DA-344 May 30, 2025
8f03384
fix on the previous commit lol
DA-344 May 30, 2025
b843272
Revert "chore: update ViewStore.dispatch_view"
DA-344 May 31, 2025
59321d3
revert " fix on the previous commit\
DA-344 May 31, 2025
e1d8a84
chore: change get_item behaviour
DA-344 Jun 1, 2025
ca62512
fix: description key always present when being None
DA-344 Jun 7, 2025
ad36136
chore: update types
DA-344 Jun 7, 2025
4f20405
chore: Add Container.type property
DA-344 Jun 7, 2025
f1c397d
typing
DA-344 Jun 7, 2025
0d86c55
chore: use a truthy check instead of a is not None
DA-344 Jun 7, 2025
d9f0be7
add attachment_id and name & size
DA-344 Jun 11, 2025
3582bf6
fix: dynamic item calls failing
DA-344 Jun 12, 2025
04d1ca0
fix: dynamic items strange cases
DA-344 Jun 12, 2025
7e071ff
chore: remove unused imports & run black
DA-344 Jun 12, 2025
4bd97e1
chore: fix messy code on ViewStore.schedule_dynamic_item_call
DA-344 Jun 13, 2025
8c807e1
chore: update some things for storing items
DA-344 Jun 13, 2025
7345812
fix: typings
DA-344 Jun 13, 2025
14bf8c1
fix: Section not having all attributes due to cls.__new__(cls)
DA-344 Jun 13, 2025
c4225ec
chore: remove unused functions and attributes
DA-344 Jun 13, 2025
3040529
chore: remove unused imports and typings
DA-344 Jun 13, 2025
3465426
chore: revert removing comments
DA-344 Jun 13, 2025
8a79252
typo
DA-344 Jun 13, 2025
3697a9b
chore: prevent storing non-interactable views and various fixes
DA-344 Jun 14, 2025
9fc0d3f
fix: ActionRow missing id
DA-344 Jun 14, 2025
5d5f4b6
fix: total_children not being updated when using add_item
DA-344 Jun 18, 2025
c03afaa
fix: views saying that arent dispatchable when they are
DA-344 Jun 18, 2025
d5d3348
merge master
DA-344 Jun 20, 2025
0342bec
update container.accent_colour to not raise errors on None
DA-344 Jun 21, 2025
06f4052
chore: Add notes on LayoutView behaviour when editing messages
DA-344 Jun 29, 2025
afedd77
Merge branch 'feat/components-v2' of https://github.com/DA-344/d.py i…
DA-344 Jun 29, 2025
67d67d3
chore: Clarify note on message edit related methods
DA-344 Jun 30, 2025
b699e7e
versionadded's and reorders
DA-344 Jun 30, 2025
0f9b605
add LayoutView to Item.view docstring
DA-344 Jun 30, 2025
c2bc491
code qol changes and docs
DA-344 Jul 28, 2025
3cf9589
merge master to feat/components-v2
DA-344 Jul 28, 2025
6a75fd9
Update discord/ui/view.py
DA-344 Jul 29, 2025
d601adf
Update discord/ui/action_row.py
DA-344 Jul 29, 2025
a8c66dc
Update discord/ui/action_row.py
DA-344 Jul 29, 2025
099bd48
use view._is_v2() instead of __discord_ui_layout_view__
DA-344 Jul 29, 2025
3cf3e1a
remove _can_be_dynamic
DA-344 Jul 29, 2025
482a1cd
remove _can_be_dynamic
DA-344 Jul 29, 2025
97932c7
Update discord/ui/media_gallery.py
DA-344 Jul 29, 2025
0a05483
rename ._is_v2() to ._is_layout()
DA-344 Jul 29, 2025
61162c6
remove outdated width property
DA-344 Jul 29, 2025
db71172
rename SectionComponent.components to SectionComponent.children
DA-344 Jul 29, 2025
5a137e8
typings and remove View.from_dict
DA-344 Jul 29, 2025
455df63
Merge branch 'feat/components-v2' of https://github.com/DA-344/d.py i…
DA-344 Jul 29, 2025
ad86240
fix docs
DA-344 Jul 29, 2025
5a5d270
typing
DA-344 Jul 29, 2025
fc6283a
Update discord/ui/container.py
DA-344 Jul 29, 2025
9f13513
Update discord/ui/section.py
DA-344 Jul 29, 2025
a1ba2f2
update ActionRow
DA-344 Jul 29, 2025
53d67e1
Merge branch 'feat/components-v2' of https://github.com/DA-344/d.py i…
DA-344 Jul 29, 2025
f1c11f1
update Section.from_component
DA-344 Jul 29, 2025
e75b1d5
remove row from v2 components, and add notes on button and select
DA-344 Jul 29, 2025
bd5e163
add note on missing places
DA-344 Jul 29, 2025
8041a08
remove MISSING check
DA-344 Jul 31, 2025
c81fa35
Merge branch 'master' of https://github.com/Rapptz/discord.py into fe…
DA-344 Jul 31, 2025
7a13bb0
run black
DA-344 Jul 31, 2025
f8ed5cb
remove unused imports
DA-344 Jul 31, 2025
12d8acb
# type: ignore
DA-344 Jul 31, 2025
5f227bf
replace \_\_discord_ui_update_view_\_ with methods
DA-344 Aug 1, 2025
ef43ef6
remove old comment
DA-344 Aug 1, 2025
5361ff1
add Item.parent property
DA-344 Aug 1, 2025
3025e3d
fix attribute errors
DA-344 Aug 1, 2025
89a2930
Update discord/ui/action_row.py
DA-344 Aug 2, 2025
478e629
typos
DA-344 Aug 2, 2025
f4a68f2
Update discord/ui/item.py
DA-344 Aug 2, 2025
917b37c
Update discord/ui/thumbnail.py
DA-344 Aug 2, 2025
eb4fe85
Update discord/ui/media_gallery.py
DA-344 Aug 2, 2025
23cfe7b
docstring
DA-344 Aug 2, 2025
79223e5
consistency
DA-344 Aug 2, 2025
f2bddc0
do actual weight checking
DA-344 Aug 2, 2025
5cb171e
changes
DA-344 Aug 2, 2025
a494bf4
Merge branch 'feat/components-v2' of https://github.com/DA-344/d.py i…
DA-344 Aug 2, 2025
291bcb2
run black
DA-344 Aug 2, 2025
8bf48e1
fix typings on interaction
DA-344 Aug 7, 2025
ce5a4be
add item._has_children
DA-344 Aug 7, 2025
d981703
remove versionchanged note on send/edit methods
DA-344 Aug 7, 2025
fc1634c
add missing id params on ActionRow.button and ActionRow.select decora…
DA-344 Aug 7, 2025
64668e7
add Section in TextDisplay docstring
DA-344 Aug 7, 2025
9ff8d82
remove unused import
DA-344 Aug 7, 2025
e1e12fe
i broke docs lol
DA-344 Aug 7, 2025
40aced5
add Separator to docstring
DA-344 Aug 7, 2025
e6d3f32
replace RuntimeError with ValueError
DA-344 Aug 7, 2025
6beab8e
replace RuntimeError with ValueError
DA-344 Aug 7, 2025
a55186d
not set rendered row in row.setter
DA-344 Aug 7, 2025
9a6b779
fix MediaGallery.id not updating the corresponding payload
DA-344 Aug 7, 2025
791331c
fix Button & Select .id not updating the corresponding payload
DA-344 Aug 7, 2025
01014f1
update ActionRow.select example
DA-344 Aug 7, 2025
0e9d25a
move custom_id stuff of Section.accessory to Section.__init__
DA-344 Aug 7, 2025
d9c4fe2
custom ids
DA-344 Aug 7, 2025
ec31af9
add Item.copy
DA-344 Aug 8, 2025
678367e
Update discord/ui/action_row.py
DA-344 Aug 11, 2025
fdbc06e
Update discord/ui/action_row.py
DA-344 Aug 11, 2025
20bf99a
Update discord/ui/action_row.py
DA-344 Aug 11, 2025
ba38075
Update discord/ui/action_row.py
DA-344 Aug 11, 2025
1452312
Update discord/ui/action_row.py
DA-344 Aug 11, 2025
90fd44e
Update discord/ui/action_row.py
DA-344 Aug 11, 2025
18850d9
Update discord/ui/action_row.py
DA-344 Aug 11, 2025
923a006
Update discord/ui/action_row.py
DA-344 Aug 11, 2025
ff80605
Update discord/ui/container.py
DA-344 Aug 11, 2025
d499c73
Update discord/ui/section.py
DA-344 Aug 11, 2025
3b8d527
Update discord/ui/section.py
DA-344 Aug 11, 2025
72e79ff
it\'s -> its
DA-344 Aug 11, 2025
5564017
Merge branch 'master' to feat/components-v2
DA-344 Aug 11, 2025
895a750
remove accessory handling in schedule_dynamic_item_call
DA-344 Aug 13, 2025
5677b3a
dont use cls, use View or LayoutView
DA-344 Aug 13, 2025
81a8884
typing
DA-344 Aug 13, 2025
9424f91
run black
DA-344 Aug 13, 2025
93ceddd
use new types instead of replacing with Any
DA-344 Aug 13, 2025
fb49079
oops
DA-344 Aug 13, 2025
5a2ad02
hmm
DA-344 Aug 13, 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
42 changes: 38 additions & 4 deletions discord/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
T = TypeVar('T', bound=VoiceProtocol)

if TYPE_CHECKING:
from typing_extensions import Self

Check warning on line 77 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 @@ -96,7 +96,7 @@
)
from .poll import Poll
from .threads import Thread
from .ui.view import View
from .ui.view import BaseView, View, LayoutView
from .types.channel import (
PermissionOverwrite as PermissionOverwritePayload,
Channel as ChannelPayload,
Expand Down Expand Up @@ -1386,6 +1386,38 @@
async def _get_channel(self) -> MessageableChannel:
raise NotImplementedError

@overload
async def send(
self,
*,
file: File = ...,
delete_after: float = ...,
nonce: Union[str, int] = ...,
allowed_mentions: AllowedMentions = ...,
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: LayoutView,
suppress_embeds: bool = ...,
silent: bool = ...,
) -> Message:
...

@overload
async def send(
self,
*,
files: Sequence[File] = ...,
delete_after: float = ...,
nonce: Union[str, int] = ...,
allowed_mentions: AllowedMentions = ...,
reference: Union[Message, MessageReference, PartialMessage] = ...,
mention_author: bool = ...,
view: LayoutView,
suppress_embeds: bool = ...,
silent: bool = ...,
) -> Message:
...

@overload
async def send(
self,
Expand Down Expand Up @@ -1485,7 +1517,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 @@ -1558,10 +1590,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 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 Expand Up @@ -1656,7 +1690,7 @@
data = await state.http.send_message(channel.id, params=params)

ret = state.create_message(channel=channel, data=data)
if view and not view.is_finished():
if view and not view.is_finished() and view.is_dispatchable():
state.store_view(view, ret.id)

if poll:
Expand Down
52 changes: 48 additions & 4 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, View, LayoutView
from .types.channel import (
TextChannel as TextChannelPayload,
NewsChannel as NewsChannelPayload,
Expand Down Expand Up @@ -2841,6 +2841,47 @@

return result

@overload
async def create_thread(
self,
*,
name: str,
auto_archive_duration: ThreadArchiveDuration = ...,
slowmode_delay: Optional[int] = ...,
file: File = ...,
files: Sequence[File] = ...,
allowed_mentions: AllowedMentions = ...,
mention_author: bool = ...,
applied_tags: Sequence[ForumTag] = ...,
view: LayoutView,
suppress_embeds: bool = ...,
reason: Optional[str] = ...,
) -> ThreadWithMessage:
...

@overload
async def create_thread(
self,
*,
name: str,
auto_archive_duration: ThreadArchiveDuration = ...,
slowmode_delay: Optional[int] = ...,
content: Optional[str] = ...,
tts: bool = ...,
embed: Embed = ...,
embeds: Sequence[Embed] = ...,
file: File = ...,
files: Sequence[File] = ...,
stickers: Sequence[Union[GuildSticker, StickerItem]] = ...,
allowed_mentions: AllowedMentions = ...,
mention_author: bool = ...,
applied_tags: Sequence[ForumTag] = ...,
view: View = ...,
suppress_embeds: bool = ...,
reason: Optional[str] = ...,
) -> ThreadWithMessage:
...

async def create_thread(
self,
*,
Expand All @@ -2857,7 +2898,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 +2948,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 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 Expand Up @@ -2983,7 +3027,7 @@
data = await state.http.start_thread_in_forum(self.id, params=params, reason=reason)
thread = Thread(guild=self.guild, state=self._state, data=data)
message = Message(state=self._state, channel=thread, data=data['message'])
if view and not view.is_finished():
if view and not view.is_finished() and view.is_dispatchable():
self._state.store_view(view, message.id)

return ThreadWithMessage(thread=thread, message=message)
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 @@ -3154,7 +3154,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 @@ -3164,8 +3164,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 @@ -3180,7 +3183,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 @@ -3192,8 +3195,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