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
@@ -1181,18 +1194,20 @@ async def edit(self, *, reason=None, **options):
11811194 async def create_thread (
11821195 self ,
11831196 name : str ,
1184- content = None ,
1197+ content : str | None = None ,
11851198 * ,
1186- embed = None ,
1187- embeds = None ,
1188- file = None ,
1189- files = None ,
1190- stickers = None ,
1191- delete_message_after = None ,
1192- nonce = None ,
1193- allowed_mentions = None ,
1194- view = None ,
1195- applied_tags = None ,
1199+ embed : Embed | None = None ,
1200+ embeds : list [Embed ] | None = None ,
1201+ file : File | None = None ,
1202+ files : list [File ] | None = None ,
1203+ stickers : Sequence [GuildSticker | StickerItem ] | None = None ,
1204+ delete_message_after : float | None = None ,
1205+ nonce : int | str | None = None ,
1206+ allowed_mentions : AllowedMentions | None = None ,
1207+ view : View | None = None ,
1208+ applied_tags : list [ForumTag ] | None = None ,
1209+ suppress : bool = False ,
1210+ silent : bool = False ,
11961211 auto_archive_duration : ThreadArchiveDuration = MISSING ,
11971212 slowmode_delay : int = MISSING ,
11981213 reason : str | None = None ,
@@ -1292,13 +1307,24 @@ async def create_thread(
12921307 else :
12931308 allowed_mentions = allowed_mentions .to_dict ()
12941309
1310+ flags = MessageFlags (
1311+ suppress_embeds = bool (suppress ),
1312+ suppress_notifications = bool (silent ),
1313+ )
1314+
12951315 if view :
12961316 if not hasattr (view , "__discord_ui_view__" ):
12971317 raise InvalidArgument (
12981318 f"view parameter must be View not { view .__class__ !r} "
12991319 )
13001320
13011321 components = view .to_components ()
1322+ if view .is_components_v2 ():
1323+ if embeds or content :
1324+ raise TypeError (
1325+ "cannot send embeds or content with a view using v2 component logic"
1326+ )
1327+ flags .is_components_v2 = True
13021328 else :
13031329 components = None
13041330
@@ -1337,6 +1363,7 @@ async def create_thread(
13371363 or self .default_auto_archive_duration ,
13381364 rate_limit_per_user = slowmode_delay or self .slowmode_delay ,
13391365 applied_tags = applied_tags ,
1366+ flags = flags .value ,
13401367 reason = reason ,
13411368 )
13421369 finally :
@@ -1346,7 +1373,7 @@ async def create_thread(
13461373
13471374 ret = Thread (guild = self .guild , state = self ._state , data = data )
13481375 msg = ret .get_partial_message (int (data ["last_message_id" ]))
1349- if view :
1376+ if view and view . is_dispatchable () :
13501377 state .store_view (view , msg .id )
13511378
13521379 if delete_message_after is not None :
0 commit comments