Skip to content

Commit

Permalink
Add support for integration_type in audit logs
Browse files Browse the repository at this point in the history
Currently unsure whether more processing is meant to be done with this,
but for now an Optional[str] is the best I can do without more data.
  • Loading branch information
Rapptz committed Aug 25, 2023
1 parent a756df3 commit 60ff239
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions discord/audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,10 @@ class _AuditLogProxyAutoModAction(_AuditLogProxy):
channel: Optional[Union[abc.GuildChannel, Thread]]


class _AuditLogProxyMemberKickOrMemberRoleUpdate(_AuditLogProxy):
integration_type: Optional[str]


class AuditLogEntry(Hashable):
r"""Represents an Audit Log entry.
Expand Down Expand Up @@ -614,6 +618,7 @@ def _from_data(self, data: AuditLogEntryPayload) -> None:
_AuditLogProxyStageInstanceAction,
_AuditLogProxyMessageBulkDelete,
_AuditLogProxyAutoModAction,
_AuditLogProxyMemberKickOrMemberRoleUpdate,
Member, User, None, PartialIntegration,
Role, Object
] = None
Expand All @@ -638,6 +643,10 @@ def _from_data(self, data: AuditLogEntryPayload) -> None:
elif self.action is enums.AuditLogAction.message_bulk_delete:
# The bulk message delete action has the number of messages deleted
self.extra = _AuditLogProxyMessageBulkDelete(count=int(extra['count']))
elif self.action in (enums.AuditLogAction.kick, enums.AuditLogAction.member_role_update):
# The member kick action has a dict with some information
integration_type = extra.get('integration_type')
self.extra = _AuditLogProxyMemberKickOrMemberRoleUpdate(integration_type=integration_type)
elif self.action.name.endswith('pin'):
# the pin actions have a dict with some information
channel_id = int(extra['channel_id'])
Expand Down
1 change: 1 addition & 0 deletions discord/types/audit_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ class AuditEntryInfo(TypedDict):
guild_id: Snowflake
auto_moderation_rule_name: str
auto_moderation_rule_trigger_type: str
integration_type: str


class AuditLogEntry(TypedDict):
Expand Down
10 changes: 10 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2106,6 +2106,11 @@ of :class:`enum.Enum`.
When this is the action, the type of :attr:`~AuditLogEntry.target` is
the :class:`User` or :class:`Object` who got kicked.

When this is the action, the type of :attr:`~AuditLogEntry.extra` is
set to an unspecified proxy object with one attribute:

- ``integration_type``: An optional string that denotes the type of integration that did the action.

When this is the action, :attr:`~AuditLogEntry.changes` is empty.

.. attribute:: member_prune
Expand Down Expand Up @@ -2166,6 +2171,11 @@ of :class:`enum.Enum`.
When this is the action, the type of :attr:`~AuditLogEntry.target` is
the :class:`Member`, :class:`User`, or :class:`Object` who got the role.

When this is the action, the type of :attr:`~AuditLogEntry.extra` is
set to an unspecified proxy object with one attribute:

- ``integration_type``: An optional string that denotes the type of integration that did the action.

Possible attributes for :class:`AuditLogDiff`:

- :attr:`~AuditLogDiff.roles`
Expand Down

0 comments on commit 60ff239

Please sign in to comment.