33
33
Iterable ,
34
34
Mapping ,
35
35
NamedTuple ,
36
+ Sequence ,
36
37
TypeVar ,
37
38
overload ,
38
39
)
55
56
)
56
57
from .errors import ClientException , InvalidArgument
57
58
from .file import File
58
- from .flags import ChannelFlags
59
+ from .flags import ChannelFlags , MessageFlags
59
60
from .invite import Invite
60
61
from .iterators import ArchivedThreadIterator
61
62
from .mixins import Hashable
83
84
84
85
if TYPE_CHECKING :
85
86
from .abc import Snowflake , SnowflakeTime
87
+ from .embeds import Embed
86
88
from .guild import Guild
87
89
from .guild import GuildChannel as GuildChannelType
88
90
from .member import Member , VoiceState
91
+ from .mentions import AllowedMentions
89
92
from .message import EmojiInputType , Message , PartialMessage
90
93
from .role import Role
91
94
from .state import ConnectionState
95
+ from .sticker import GuildSticker , StickerItem
92
96
from .types .channel import CategoryChannel as CategoryChannelPayload
93
97
from .types .channel import DMChannel as DMChannelPayload
94
98
from .types .channel import ForumChannel as ForumChannelPayload
100
104
from .types .channel import VoiceChannelEffectSendEvent as VoiceChannelEffectSend
101
105
from .types .snowflake import SnowflakeList
102
106
from .types .threads import ThreadArchiveDuration
107
+ from .ui .view import View
103
108
from .user import BaseUser , ClientUser , User
104
109
from .webhook import Webhook
105
110
@@ -1194,18 +1199,20 @@ async def edit(self, *, reason=None, **options):
1194
1199
async def create_thread (
1195
1200
self ,
1196
1201
name : str ,
1197
- content = None ,
1202
+ content : str | None = None ,
1198
1203
* ,
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 ,
1209
1216
auto_archive_duration : ThreadArchiveDuration = MISSING ,
1210
1217
slowmode_delay : int = MISSING ,
1211
1218
reason : str | None = None ,
@@ -1305,13 +1312,24 @@ async def create_thread(
1305
1312
else :
1306
1313
allowed_mentions = allowed_mentions .to_dict ()
1307
1314
1315
+ flags = MessageFlags (
1316
+ suppress_embeds = bool (suppress ),
1317
+ suppress_notifications = bool (silent ),
1318
+ )
1319
+
1308
1320
if view :
1309
1321
if not hasattr (view , "__discord_ui_view__" ):
1310
1322
raise InvalidArgument (
1311
1323
f"view parameter must be View not { view .__class__ !r} "
1312
1324
)
1313
1325
1314
1326
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
1315
1333
else :
1316
1334
components = None
1317
1335
@@ -1350,6 +1368,7 @@ async def create_thread(
1350
1368
or self .default_auto_archive_duration ,
1351
1369
rate_limit_per_user = slowmode_delay or self .slowmode_delay ,
1352
1370
applied_tags = applied_tags ,
1371
+ flags = flags .value ,
1353
1372
reason = reason ,
1354
1373
)
1355
1374
finally :
@@ -1359,7 +1378,7 @@ async def create_thread(
1359
1378
1360
1379
ret = Thread (guild = self .guild , state = self ._state , data = data )
1361
1380
msg = ret .get_partial_message (int (data ["last_message_id" ]))
1362
- if view :
1381
+ if view and view . is_dispatchable () :
1363
1382
state .store_view (view , msg .id )
1364
1383
1365
1384
if delete_message_after is not None :
0 commit comments