@@ -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' ]))
@@ -645,26 +654,29 @@ async def edit(
645
654
roles : List [discord .abc .Snowflake ] = MISSING ,
646
655
voice_channel : Optional [VocalGuildChannel ] = MISSING ,
647
656
reason : Optional [str ] = None ,
657
+ communication_disabled_until : Optional [datetime .datetime ] = MISSING ,
648
658
) -> Optional [Member ]:
649
659
"""|coro|
650
660
651
661
Edits the member's data.
652
662
653
663
Depending on the parameter passed, this requires different permissions listed below:
654
664
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
- +---------------+--------------------------------------+
665
+ +------------------------------+--------------------------------------+
666
+ | Parameter | Permission |
667
+ +------------------------------+--------------------------------------+
668
+ | nick | :attr:`Permissions.manage_nicknames` |
669
+ +------------------------------+--------------------------------------+
670
+ | mute | :attr:`Permissions.mute_members` |
671
+ +------------------------------+--------------------------------------+
672
+ | deafen | :attr:`Permissions.deafen_members` |
673
+ +------------------------------+--------------------------------------+
674
+ | roles | :attr:`Permissions.manage_roles` |
675
+ +------------------------------+--------------------------------------+
676
+ | voice_channel | :attr:`Permissions.move_members` |
677
+ +------------------------------+--------------------------------------+
678
+ | communication_disabled_until | :attr:`Permissions.manage_members` |
679
+ +------------------------------+--------------------------------------+
668
680
669
681
All parameters are optional.
670
682
@@ -694,7 +706,11 @@ async def edit(
694
706
Pass ``None`` to kick them from voice.
695
707
reason: Optional[:class:`str`]
696
708
The reason for editing this member. Shows up on the audit log.
709
+ communication_disabled_until: Optional[:class:`datetime.datetime`]
710
+ Temporarily puts the member in timeout until this time. If the value is ``None``, then the user is removed
711
+ from timeout.
697
712
713
+ .. versionadded:: 2.0
698
714
Raises
699
715
-------
700
716
Forbidden
@@ -748,10 +764,64 @@ async def edit(
748
764
if roles is not MISSING :
749
765
payload ['roles' ] = tuple (r .id for r in roles )
750
766
767
+ if communication_disabled_until is not MISSING :
768
+ if communication_disabled_until is not None :
769
+ payload ['communication_disabled_until' ] = communication_disabled_until .isoformat ()
770
+ else :
771
+ payload ['communication_disabled_until' ] = communication_disabled_until
772
+
751
773
if payload :
752
774
data = await http .edit_member (guild_id , self .id , reason = reason , ** payload )
753
775
return Member (data = data , guild = self .guild , state = self ._state )
754
776
777
+ async def timeout (self , until : Optional [datetime .datetime ], reason : str = None ) -> None :
778
+ """|coro|
779
+
780
+ Timeouts a member from the guild for the set duration.
781
+
782
+ You must have the :attr:`~Permissions.manage_members` permission to
783
+ timeout a member.
784
+
785
+ Parameters
786
+ -----------
787
+ until: :class:`datetime.datetime`
788
+ The date and time to timeout the member for. If this is ``None`` then the member is removed from timeout.
789
+ reason: Optional[:class:`str`]
790
+ The reason for doing this action. Shows up on the audit log.
791
+
792
+ Raises
793
+ -------
794
+ Forbidden
795
+ You do not have permissions to timeout members.
796
+ HTTPException
797
+ An error occurred doing the request.
798
+ """
799
+ await self .edit (communication_disabled_until = until , reason = reason )
800
+
801
+ async def remove_timeout (self , reason : str = None ) -> None :
802
+ """|coro|
803
+
804
+ Removes the timeout from a member.
805
+
806
+ You must have the :attr:`~Permissions.manage_members` permission to
807
+ remove the timeout.
808
+
809
+ This is equivalent to calling :meth:`~.timeout` and passing ``None`` to :param:`~.timeout.until`.
810
+
811
+ Parameters
812
+ -----------
813
+ reason: Optional[:class:`str`]
814
+ The reason for doing this action. Shows up on the audit log.
815
+
816
+ Raises
817
+ -------
818
+ Forbidden
819
+ You do not have permissions to remove the timeout.
820
+ HTTPException
821
+ An error occurred doing the request.
822
+ """
823
+ await self .edit (communication_disabled_until = None , reason = reason )
824
+
755
825
async def request_to_speak (self ) -> None :
756
826
"""|coro|
757
827
0 commit comments