3333 Iterable ,
3434 Mapping ,
3535 NamedTuple ,
36+ Sequence ,
3637 TypeVar ,
3738 overload ,
3839)
5556)
5657from .errors import ClientException , InvalidArgument
5758from .file import File
58- from .flags import ChannelFlags
59+ from .flags import ChannelFlags , MessageFlags
5960from .invite import Invite
6061from .iterators import ArchivedThreadIterator
6162from .mixins import Hashable
8384
8485if TYPE_CHECKING :
8586 from .abc import Snowflake , SnowflakeTime
87+ from .embeds import Embed
8688 from .guild import Guild
8789 from .guild import GuildChannel as GuildChannelType
8890 from .member import Member , VoiceState
91+ from .mentions import AllowedMentions
8992 from .message import EmojiInputType , Message , PartialMessage
9093 from .role import Role
9194 from .state import ConnectionState
95+ from .sticker import GuildSticker , StickerItem
9296 from .types .channel import CategoryChannel as CategoryChannelPayload
9397 from .types .channel import DMChannel as DMChannelPayload
9498 from .types .channel import ForumChannel as ForumChannelPayload
100104 from .types .channel import VoiceChannelEffectSendEvent as VoiceChannelEffectSend
101105 from .types .snowflake import SnowflakeList
102106 from .types .threads import ThreadArchiveDuration
107+ from .ui .view import View
103108 from .user import BaseUser , ClientUser , User
104109 from .webhook import Webhook
105110
@@ -1194,18 +1199,20 @@ async def edit(self, *, reason=None, **options):
11941199 async def create_thread (
11951200 self ,
11961201 name : str ,
1197- content = None ,
1202+ content : str | None = None ,
11981203 * ,
1199- embed = None ,
1200- embeds = None ,
1201- file = None ,
1202- files = None ,
1203- stickers = None ,
1204- delete_message_after = None ,
1205- nonce = None ,
1206- allowed_mentions = None ,
1207- view = None ,
1208- applied_tags = None ,
1204+ embed : Embed | None = None ,
1205+ embeds : list [Embed ] | None = None ,
1206+ file : File | None = None ,
1207+ files : list [File ] | None = None ,
1208+ stickers : Sequence [GuildSticker | StickerItem ] | None = None ,
1209+ delete_message_after : float | None = None ,
1210+ nonce : int | str | None = None ,
1211+ allowed_mentions : AllowedMentions | None = None ,
1212+ view : View | None = None ,
1213+ applied_tags : list [ForumTag ] | None = None ,
1214+ suppress : bool = False ,
1215+ silent : bool = False ,
12091216 auto_archive_duration : ThreadArchiveDuration = MISSING ,
12101217 slowmode_delay : int = MISSING ,
12111218 reason : str | None = None ,
@@ -1305,13 +1312,24 @@ async def create_thread(
13051312 else :
13061313 allowed_mentions = allowed_mentions .to_dict ()
13071314
1315+ flags = MessageFlags (
1316+ suppress_embeds = bool (suppress ),
1317+ suppress_notifications = bool (silent ),
1318+ )
1319+
13081320 if view :
13091321 if not hasattr (view , "__discord_ui_view__" ):
13101322 raise InvalidArgument (
13111323 f"view parameter must be View not { view .__class__ !r} "
13121324 )
13131325
13141326 components = view .to_components ()
1327+ if view .is_components_v2 ():
1328+ if embeds or content :
1329+ raise TypeError (
1330+ "cannot send embeds or content with a view using v2 component logic"
1331+ )
1332+ flags .is_components_v2 = True
13151333 else :
13161334 components = None
13171335
@@ -1350,6 +1368,7 @@ async def create_thread(
13501368 or self .default_auto_archive_duration ,
13511369 rate_limit_per_user = slowmode_delay or self .slowmode_delay ,
13521370 applied_tags = applied_tags ,
1371+ flags = flags .value ,
13531372 reason = reason ,
13541373 )
13551374 finally :
@@ -1359,7 +1378,7 @@ async def create_thread(
13591378
13601379 ret = Thread (guild = self .guild , state = self ._state , data = data )
13611380 msg = ret .get_partial_message (int (data ["last_message_id" ]))
1362- if view :
1381+ if view and view . is_dispatchable () :
13631382 state .store_view (view , msg .id )
13641383
13651384 if delete_message_after is not None :
0 commit comments