2626from __future__ import annotations
2727
2828import datetime
29- from typing import TYPE_CHECKING , Any , Callable , Iterable , Mapping , TypeVar , overload
29+ from typing import (
30+ TYPE_CHECKING ,
31+ Any ,
32+ Callable ,
33+ Iterable ,
34+ Mapping ,
35+ Sequence ,
36+ TypeVar ,
37+ overload ,
38+ )
3039
3140import discord .abc
3241
4554)
4655from .errors import ClientException , InvalidArgument
4756from .file import File
48- from .flags import ChannelFlags
57+ from .flags import ChannelFlags , MessageFlags
4958from .invite import Invite
5059from .iterators import ArchivedThreadIterator
5160from .mixins import Hashable
7180
7281if TYPE_CHECKING :
7382 from .abc import Snowflake , SnowflakeTime
83+ from .embeds import Embed
7484 from .guild import Guild
7585 from .guild import GuildChannel as GuildChannelType
7686 from .member import Member , VoiceState
87+ from .mentions import AllowedMentions
7788 from .message import EmojiInputType , Message , PartialMessage
7889 from .role import Role
7990 from .state import ConnectionState
91+ from .sticker import GuildSticker , StickerItem
8092 from .types .channel import CategoryChannel as CategoryChannelPayload
8193 from .types .channel import DMChannel as DMChannelPayload
8294 from .types .channel import ForumChannel as ForumChannelPayload
8799 from .types .channel import VoiceChannel as VoiceChannelPayload
88100 from .types .snowflake import SnowflakeList
89101 from .types .threads import ThreadArchiveDuration
102+ from .ui .view import View
90103 from .user import BaseUser , ClientUser , User
91104 from .webhook import Webhook
92105
@@ -1183,18 +1196,20 @@ async def edit(self, *, reason=None, **options):
11831196 async def create_thread (
11841197 self ,
11851198 name : str ,
1186- content = None ,
1199+ content : str | None = None ,
11871200 * ,
1188- embed = None ,
1189- embeds = None ,
1190- file = None ,
1191- files = None ,
1192- stickers = None ,
1193- delete_message_after = None ,
1194- nonce = None ,
1195- allowed_mentions = None ,
1196- view = None ,
1197- applied_tags = None ,
1201+ embed : Embed | None = None ,
1202+ embeds : list [Embed ] | None = None ,
1203+ file : File | None = None ,
1204+ files : list [File ] | None = None ,
1205+ stickers : Sequence [GuildSticker | StickerItem ] | None = None ,
1206+ delete_message_after : float | None = None ,
1207+ nonce : int | str | None = None ,
1208+ allowed_mentions : AllowedMentions | None = None ,
1209+ view : View | None = None ,
1210+ applied_tags : list [ForumTag ] | None = None ,
1211+ suppress : bool = False ,
1212+ silent : bool = False ,
11981213 auto_archive_duration : ThreadArchiveDuration = MISSING ,
11991214 slowmode_delay : int = MISSING ,
12001215 reason : str | None = None ,
@@ -1294,13 +1309,24 @@ async def create_thread(
12941309 else :
12951310 allowed_mentions = allowed_mentions .to_dict ()
12961311
1312+ flags = MessageFlags (
1313+ suppress_embeds = bool (suppress ),
1314+ suppress_notifications = bool (silent ),
1315+ )
1316+
12971317 if view :
12981318 if not hasattr (view , "__discord_ui_view__" ):
12991319 raise InvalidArgument (
13001320 f"view parameter must be View not { view .__class__ !r} "
13011321 )
13021322
13031323 components = view .to_components ()
1324+ if view .is_components_v2 ():
1325+ if embeds or content :
1326+ raise TypeError (
1327+ "cannot send embeds or content with a view using v2 component logic"
1328+ )
1329+ flags .is_components_v2 = True
13041330 else :
13051331 components = None
13061332
@@ -1339,6 +1365,7 @@ async def create_thread(
13391365 or self .default_auto_archive_duration ,
13401366 rate_limit_per_user = slowmode_delay or self .slowmode_delay ,
13411367 applied_tags = applied_tags ,
1368+ flags = flags .value ,
13421369 reason = reason ,
13431370 )
13441371 finally :
@@ -1348,7 +1375,7 @@ async def create_thread(
13481375
13491376 ret = Thread (guild = self .guild , state = self ._state , data = data )
13501377 msg = ret .get_partial_message (int (data ["last_message_id" ]))
1351- if view :
1378+ if view and view . is_dispatchable () :
13521379 state .store_view (view , msg .id )
13531380
13541381 if delete_message_after is not None :
0 commit comments