30
30
import itertools
31
31
import sys
32
32
from operator import attrgetter
33
- from typing import Any , Dict , List , Literal , Optional , TYPE_CHECKING , Tuple , Type , TypeVar , Union , overload
33
+ from typing import Any , Dict , List , Literal , Optional , TYPE_CHECKING , Tuple , Type , TypeVar , Union
34
34
35
35
import discord .abc
36
-
37
36
from . import utils
38
- from .asset import Asset
39
- from .utils import MISSING
40
- from .user import BaseUser , User , _UserTag
41
37
from .activity import create_activity , ActivityTypes
42
- from .permissions import Permissions
43
- from .enums import Status , try_enum
44
38
from .colour import Colour
39
+ from .enums import Status , try_enum
45
40
from .object import Object
41
+ from .permissions import Permissions
42
+ from .user import BaseUser , User , _UserTag
43
+ from .utils import MISSING
46
44
47
45
__all__ = (
48
46
'VoiceState' ,
@@ -788,10 +786,9 @@ async def edit(
788
786
async def timeout (self , until : Optional [datetime .datetime ], * , reason : Optional [str ] = None ) -> None :
789
787
"""|coro|
790
788
791
- Timeouts a member from the guild for the set duration .
789
+ Applies a timeout to a member in the guild until a set datetime .
792
790
793
- You must have the :attr:`~Permissions.moderate_members` permission to
794
- timeout a member.
791
+ You must have the :attr:`~Permissions.moderate_members` permission to timeout a member.
795
792
796
793
Parameters
797
794
-----------
@@ -809,6 +806,31 @@ async def timeout(self, until: Optional[datetime.datetime], *, reason: Optional[
809
806
"""
810
807
await self .edit (communication_disabled_until = until , reason = reason )
811
808
809
+ async def timeout_for (self , duration : datetime .timedelta , * , reason : Optional [str ] = None ) -> None :
810
+ """|coro|
811
+
812
+ Applies a timeout to a member in the guild for a set duration. A shortcut method for :meth:`~.timeout`, and
813
+ equivalent to ``timeout(until=datetime.utcnow() + duration, reason=reason)``.
814
+
815
+ You must have the :attr:`~Permissions.moderate_members` permission to
816
+ timeout a member.
817
+
818
+ Parameters
819
+ -----------
820
+ duration: :class:`datetime.timedelta`
821
+ The duration to timeout the member for.
822
+ reason: Optional[:class:`str`]
823
+ The reason for doing this action. Shows up on the audit log.
824
+
825
+ Raises
826
+ -------
827
+ Forbidden
828
+ You do not have permissions to timeout members.
829
+ HTTPException
830
+ An error occurred doing the request.
831
+ """
832
+ await self .timeout (datetime .datetime .now (datetime .timezone .utc ) + duration , reason = reason )
833
+
812
834
async def remove_timeout (self , * , reason : Optional [str ] = None ) -> None :
813
835
"""|coro|
814
836
0 commit comments