25
25
"""
26
26
from __future__ import annotations
27
27
28
+ import asyncio
28
29
import datetime
29
30
import time
30
- import asyncio
31
-
32
31
from typing import (
33
- TYPE_CHECKING ,
32
+ Any ,
34
33
Callable ,
35
- Union ,
36
- Optional ,
37
- Sequence ,
38
34
Coroutine ,
35
+ Dict ,
39
36
List ,
37
+ Optional ,
38
+ Sequence ,
40
39
Tuple ,
41
- Dict ,
42
- Any
40
+ TYPE_CHECKING ,
41
+ Union
43
42
)
44
43
45
- from .permissions import Permissions , PermissionOverwrite
46
- from .enums import ChannelType , VoiceRegion , AutoArchiveDuration , PostSortOrder , try_enum
47
- from .components import Button , SelectMenu , ActionRow
48
- from .iterators import ThreadMemberIterator
49
- from .mixins import Hashable
50
- from . import utils , abc
51
- from .flags import ChannelFlags
44
+ from . import abc , utils
52
45
from .asset import Asset
53
- from .errors import ClientException , NoMoreItems , InvalidArgument , ThreadIsArchived
46
+ from .components import ActionRow , BaseSelect , Button
47
+ from .enums import AutoArchiveDuration , ChannelType , PostSortOrder , try_enum , VoiceRegion
48
+ from .errors import ClientException , InvalidArgument , NoMoreItems , ThreadIsArchived
49
+ from .flags import ChannelFlags , MessageFlags
54
50
from .http import handle_message_parameters
51
+ from .iterators import ThreadMemberIterator
52
+ from .mixins import Hashable
55
53
from .partial_emoji import PartialEmoji
54
+ from .permissions import PermissionOverwrite , Permissions
56
55
57
56
if TYPE_CHECKING :
58
57
from .state import ConnectionState
@@ -1072,7 +1071,7 @@ async def remove_member(self, member: Union[Member, int]):
1072
1071
1073
1072
return await self ._state .http .remove_thread_member (channel_id = self .id , member_id = member_id )
1074
1073
1075
- async def fetch_members (
1074
+ def fetch_members (
1076
1075
self ,
1077
1076
limit : int = 100 ,
1078
1077
after : Union [abc .Snowflake , datetime .datetime ] = None ,
@@ -1081,36 +1080,42 @@ async def fetch_members(
1081
1080
"""Returns a :class:`ThreadMemberIterator` that allows to retrieve the currently joined members of this thread.
1082
1081
1083
1082
.. note::
1084
-
1085
- This requires :func:`Intents.members` to be enabled and will also add the members retrieved to :attr:`members`
1083
+ This requires the :func:`~Intents.members` intent to be enabled and will also add the members retrieved to :attr:`members`
1086
1084
1087
1085
Examples
1088
1086
---------
1089
-
1087
+
1090
1088
Usage ::
1091
-
1092
- print(f"The thread {channel.name} has the following members:\n ")
1089
+
1090
+ print(f"The thread {channel.name} has the following members:\\ n")
1093
1091
async for member in thread.fetch_members(limit=200):
1094
1092
print(member)
1095
1093
1096
- Flattening into a list: ::
1094
+
1095
+ Flattening into a list ::
1097
1096
1098
1097
messages = await thread.fetch_members(limit=123).flatten()
1099
1098
# messages is now a list of ThreadMember...
1100
1099
1100
+
1101
1101
All parameters are optional.
1102
1102
1103
1103
Parameters
1104
- -----------
1104
+ ----------
1105
1105
limit: :class:`int`
1106
1106
The limit of thread members to retrieve - defaults to 100
1107
1107
after: Union[:class:`int`, :class:`datetime.datetime`]
1108
1108
Get thread members after this user ID
1109
1109
1110
+ Raises
1111
+ ------
1112
+ ~discord.ClientException
1113
+ The :attr:`~Intents.members` intent is not enabled.
1114
+
1110
1115
Yields
1111
1116
-------
1112
1117
:class:`~discord.ThreadMember`
1113
- The thread member
1118
+ A member of this thread
1114
1119
"""
1115
1120
if not self ._state .intents .members :
1116
1121
raise ClientException ('You need to enable the GUILD_MEMBERS Intent to use this API-call.' )
@@ -2831,21 +2836,19 @@ async def create_post(
2831
2836
content : Any = None ,
2832
2837
embed : Optional [Embed ] = None ,
2833
2838
embeds : Sequence [Embed ] = None ,
2834
- components : Optional [List [Union [ActionRow , List [Union [Button , SelectMenu ]]]]] = None ,
2839
+ components : Optional [List [Union [ActionRow , List [Union [Button , BaseSelect ]]]]] = None ,
2835
2840
file : Optional [File ] = None ,
2836
2841
files : Sequence [File ] = None ,
2837
2842
allowed_mentions : Optional [AllowedMentions ] = None ,
2838
- suppress : bool = False ,
2843
+ suppress_embeds : bool = False ,
2844
+ supress_notifications : bool = False ,
2839
2845
auto_archive_duration : Optional [AutoArchiveDuration ] = None ,
2840
2846
slowmode_delay : int = 0 ,
2841
2847
reason : Optional [str ] = None
2842
2848
) -> ForumPost :
2843
2849
"""|coro|
2844
2850
2845
- Creates a new post in this forum.
2846
-
2847
- You must have the :attr:`~Permissions.create_posts` permission to
2848
- use this.
2851
+ Creates a new post in this forum. Requires the :attr:`~Permissions.create_posts` permission.
2849
2852
2850
2853
Parameters
2851
2854
-----------
@@ -2860,16 +2863,20 @@ async def create_post(
2860
2863
A embed of the post starter-message.
2861
2864
embeds: List[:class:`Embed`]
2862
2865
A list of up to 10 embeds to include in the post starter-message.
2863
- components: List[Union[:class:`ActionRow`, List[Union[:class:`Button`, :class:`SelectMenu `]]]]
2866
+ components: List[Union[:class:`ActionRow`, List[Union[:class:`Button`, :class:`BaseSelect `]]]]
2864
2867
A list of components to include in the post starter-message.
2865
2868
file: Optional[class:`File`]
2866
2869
A file to include in the post starter-message.
2867
2870
files: List[:class:`File`]
2868
2871
A list of files to include in the post starter-message.
2869
2872
allowed_mentions: Optional[:class:`AllowedMentions`]
2870
2873
The allowed mentions for the post.
2871
- suppress : Optional[:class:`bool`]
2874
+ suppress_embeds : Optional[:class:`bool`]
2872
2875
Whether to suppress embeds in the post starter-message.
2876
+ supress_notifications: Optional[:class:`bool`]
2877
+ Whether to suppress desktop- & push-notifications for the post starter-message.
2878
+
2879
+ Users will still see a ping-symbol when they are mentioned in the message, or the message is in a dm channel.
2873
2880
auto_archive_duration: Optional[:class:`AutoArchiveDuration`]
2874
2881
The duration after the post will be archived automatically when inactive.
2875
2882
slowmode_delay: Optional[:class:`int`]
@@ -2895,10 +2902,10 @@ async def create_post(
2895
2902
if self .flags .require_tags and not tags :
2896
2903
raise InvalidArgument ('This forum requires at least one tag provided when creating a post.' )
2897
2904
2898
- if suppress :
2899
- from .message import MessageFlags
2905
+ if suppress_embeds or supress_notifications :
2900
2906
flags = MessageFlags ._from_value (0 )
2901
- flags .suppress_embeds = True
2907
+ flags .suppress_embeds = suppress_embeds
2908
+ flags .suppress_notifications = supress_notifications
2902
2909
else :
2903
2910
flags = MISSING
2904
2911
@@ -3060,4 +3067,4 @@ def _channel_factory(channel_type):
3060
3067
def _check_channel_type (obj , types ) -> bool :
3061
3068
"""Just something to check channel instances without circular imports."""
3062
3069
types = tuple ([_channel_factory (t )[0 ] for t in types ])
3063
- return isinstance (obj , types )
3070
+ return isinstance (obj , types )
0 commit comments