@@ -252,6 +252,10 @@ class Member(discord.abc.Messageable, _UserTag):
252
252
premium_since: Optional[:class:`datetime.datetime`]
253
253
An aware datetime object that specifies the date and time in UTC when the member used their
254
254
"Nitro boost" on the guild, if available. This could be ``None``.
255
+ communication_disabled_until: Optional[:class:`datetime.datetime`]
256
+ An aware datetime object that specifies the date and time in UTC when the member will be removed from timeout.
257
+
258
+ .. versionadded:: 2.0
255
259
"""
256
260
257
261
__slots__ = (
@@ -266,6 +270,7 @@ class Member(discord.abc.Messageable, _UserTag):
266
270
'_user' ,
267
271
'_state' ,
268
272
'_avatar' ,
273
+ 'communication_disabled_until' ,
269
274
)
270
275
271
276
if TYPE_CHECKING :
@@ -284,6 +289,7 @@ class Member(discord.abc.Messageable, _UserTag):
284
289
banner : Optional [Asset ]
285
290
accent_color : Optional [Colour ]
286
291
accent_colour : Optional [Colour ]
292
+ communication_disabled_until : Optional [datetime .datetime ]
287
293
288
294
def __init__ (self , * , data : MemberWithUserPayload , guild : Guild , state : ConnectionState ):
289
295
self ._state : ConnectionState = state
@@ -297,6 +303,7 @@ def __init__(self, *, data: MemberWithUserPayload, guild: Guild, state: Connecti
297
303
self .nick : Optional [str ] = data .get ('nick' , None )
298
304
self .pending : bool = data .get ('pending' , False )
299
305
self ._avatar : Optional [str ] = data .get ('avatar' )
306
+ self .communication_disabled_until : Optional [datetime .datetime ] = utils .parse_time (data .get ('communication_disabled_until' ))
300
307
301
308
def __str__ (self ) -> str :
302
309
return str (self ._user )
@@ -354,6 +361,7 @@ def _copy(cls: Type[M], member: M) -> M:
354
361
self .activities = member .activities
355
362
self ._state = member ._state
356
363
self ._avatar = member ._avatar
364
+ self .communication_disabled_until = member .communication_disabled_until
357
365
358
366
# Reference will not be copied unless necessary by PRESENCE_UPDATE
359
367
# See below
@@ -380,6 +388,7 @@ def _update(self, data: MemberPayload) -> None:
380
388
self .premium_since = utils .parse_time (data .get ('premium_since' ))
381
389
self ._roles = utils .SnowflakeList (map (int , data ['roles' ]))
382
390
self ._avatar = data .get ('avatar' )
391
+ self .communication_disabled_until = utils .parse_time (data .get ('communication_disabled_until' ))
383
392
384
393
def _presence_update (self , data : PartialPresenceUpdate , user : UserPayload ) -> Optional [Tuple [User , User ]]:
385
394
self .activities = tuple (map (create_activity , data ['activities' ]))
@@ -405,7 +414,9 @@ def _update_inner_user(self, user: UserPayload) -> Optional[Tuple[User, User]]:
405
414
406
415
@property
407
416
def status (self ) -> Status :
408
- """:class:`Status`: The member's overall status. If the value is unknown, then it will be a :class:`str` instead."""
417
+ """:class:`Status`: The member's overall status.
418
+ If the value is unknown, then it will be a :class:`str` instead.
419
+ """
409
420
return try_enum (Status , self ._client_status [None ])
410
421
411
422
@property
@@ -645,26 +656,29 @@ async def edit(
645
656
roles : List [discord .abc .Snowflake ] = MISSING ,
646
657
voice_channel : Optional [VocalGuildChannel ] = MISSING ,
647
658
reason : Optional [str ] = None ,
659
+ communication_disabled_until : Optional [datetime .datetime ] = MISSING ,
648
660
) -> Optional [Member ]:
649
661
"""|coro|
650
662
651
663
Edits the member's data.
652
664
653
665
Depending on the parameter passed, this requires different permissions listed below:
654
666
655
- +---------------+--------------------------------------+
656
- | Parameter | Permission |
657
- +---------------+--------------------------------------+
658
- | nick | :attr:`Permissions.manage_nicknames` |
659
- +---------------+--------------------------------------+
660
- | mute | :attr:`Permissions.mute_members` |
661
- +---------------+--------------------------------------+
662
- | deafen | :attr:`Permissions.deafen_members` |
663
- +---------------+--------------------------------------+
664
- | roles | :attr:`Permissions.manage_roles` |
665
- +---------------+--------------------------------------+
666
- | voice_channel | :attr:`Permissions.move_members` |
667
- +---------------+--------------------------------------+
667
+ +------------------------------+--------------------------------------+
668
+ | Parameter | Permission |
669
+ +------------------------------+--------------------------------------+
670
+ | nick | :attr:`Permissions.manage_nicknames` |
671
+ +------------------------------+--------------------------------------+
672
+ | mute | :attr:`Permissions.mute_members` |
673
+ +------------------------------+--------------------------------------+
674
+ | deafen | :attr:`Permissions.deafen_members` |
675
+ +------------------------------+--------------------------------------+
676
+ | roles | :attr:`Permissions.manage_roles` |
677
+ +------------------------------+--------------------------------------+
678
+ | voice_channel | :attr:`Permissions.move_members` |
679
+ +------------------------------+--------------------------------------+
680
+ | communication_disabled_until | :attr:`Permissions.moderate_members` |
681
+ +------------------------------+--------------------------------------+
668
682
669
683
All parameters are optional.
670
684
@@ -694,7 +708,11 @@ async def edit(
694
708
Pass ``None`` to kick them from voice.
695
709
reason: Optional[:class:`str`]
696
710
The reason for editing this member. Shows up on the audit log.
711
+ communication_disabled_until: Optional[:class:`datetime.datetime`]
712
+ Temporarily puts the member in timeout until this time. If the value is ``None``, then the user is removed
713
+ from timeout.
697
714
715
+ .. versionadded:: 2.0
698
716
Raises
699
717
-------
700
718
Forbidden
@@ -748,10 +766,64 @@ async def edit(
748
766
if roles is not MISSING :
749
767
payload ['roles' ] = tuple (r .id for r in roles )
750
768
769
+ if communication_disabled_until is not MISSING :
770
+ if communication_disabled_until is not None :
771
+ payload ['communication_disabled_until' ] = communication_disabled_until .isoformat ()
772
+ else :
773
+ payload ['communication_disabled_until' ] = communication_disabled_until
774
+
751
775
if payload :
752
776
data = await http .edit_member (guild_id , self .id , reason = reason , ** payload )
753
777
return Member (data = data , guild = self .guild , state = self ._state )
754
778
779
+ async def timeout (self , until : Optional [datetime .datetime ], reason : str = None ) -> None :
780
+ """|coro|
781
+
782
+ Timeouts a member from the guild for the set duration.
783
+
784
+ You must have the :attr:`~Permissions.moderate_members` permission to
785
+ timeout a member.
786
+
787
+ Parameters
788
+ -----------
789
+ until: :class:`datetime.datetime`
790
+ The date and time to timeout the member for. If this is ``None`` then the member is removed from timeout.
791
+ reason: Optional[:class:`str`]
792
+ The reason for doing this action. Shows up on the audit log.
793
+
794
+ Raises
795
+ -------
796
+ Forbidden
797
+ You do not have permissions to timeout members.
798
+ HTTPException
799
+ An error occurred doing the request.
800
+ """
801
+ await self .edit (communication_disabled_until = until , reason = reason )
802
+
803
+ async def remove_timeout (self , reason : str = None ) -> None :
804
+ """|coro|
805
+
806
+ Removes the timeout from a member.
807
+
808
+ You must have the :attr:`~Permissions.moderate_members` permission to
809
+ remove the timeout.
810
+
811
+ This is equivalent to calling :meth:`~.timeout` and passing ``None`` to :param:`~.timeout.until`.
812
+
813
+ Parameters
814
+ -----------
815
+ reason: Optional[:class:`str`]
816
+ The reason for doing this action. Shows up on the audit log.
817
+
818
+ Raises
819
+ -------
820
+ Forbidden
821
+ You do not have permissions to remove the timeout.
822
+ HTTPException
823
+ An error occurred doing the request.
824
+ """
825
+ await self .edit (communication_disabled_until = None , reason = reason )
826
+
755
827
async def request_to_speak (self ) -> None :
756
828
"""|coro|
757
829
0 commit comments