Skip to content

Commit 6257ea0

Browse files
committed
✨ Implement and document AuditLogDiff.communication_disabled_until
1 parent a6b6922 commit 6257ea0

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

discord/audit_logs.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
from __future__ import annotations
2727

28+
import datetime
2829
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Generator, TypeVar
2930

3031
from . import enums, utils
@@ -44,8 +45,6 @@
4445

4546

4647
if TYPE_CHECKING:
47-
import datetime
48-
4948
from . import abc
5049
from .emoji import GuildEmoji
5150
from .guild import Guild
@@ -209,6 +208,14 @@ def _transform_trigger_metadata(
209208
return AutoModTriggerMetadata.from_dict(data)
210209

211210

211+
def _transform_communication_disabled_until(
212+
entry: AuditLogEntry, data: str
213+
) -> datetime.datetime | None:
214+
if data:
215+
return datetime.datetime.fromisoformat(data)
216+
return None
217+
218+
212219
class AuditLogDiff:
213220
def __len__(self) -> int:
214221
return len(self.__dict__)
@@ -281,6 +288,7 @@ class AuditLogChanges:
281288
"trigger_metadata": (None, _transform_trigger_metadata),
282289
"exempt_roles": (None, _transform_roles),
283290
"exempt_channels": (None, _transform_channels),
291+
"communication_disabled_until": (None, _transform_communication_disabled_until),
284292
}
285293

286294
def __init__(

docs/api/audit_logs.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,17 @@ this goal, it must make use of a couple of data classes that aid in this goal.
524524

525525
:type: :class:`str`
526526

527-
.. attribute:: image
527+
.. attribute:: image
528528

529-
The cover image of a :class:`ScheduledEvent`.
529+
The cover image of a :class:`ScheduledEvent`.
530530

531-
:type: :class:`str`
531+
:type: :class:`str`
532+
533+
.. attribute:: communication_disabled_until
534+
535+
Until when a :class:`Member` will be timed out
536+
537+
:type: :class:`datetime.datetime` | :data:`None`
532538

533539
.. this is currently missing the following keys: reason and application_id
534540
I'm not sure how to about porting these

0 commit comments

Comments
 (0)