Audit

discord_http.audit module

class discord_http.audit.AuditChange(*, entry, data)

Bases: Generic[_AuditChangeT]

Represents a change in an audit log entry.

Parameters:
entry: AuditLogEntry

The audit log entry this change belongs to.

key: str

The key of the change.

new_value: _AuditChangeT | None

The new value of the change, if applicable.

old_value: _AuditChangeT | None

The old value of the change, if applicable.

class discord_http.audit.AuditLogEntry(*, state, data, guild=None, users=None)

Bases: Snowflake

Represents an entry in an audit log.

Parameters:
guild: PartialGuild

The guild this audit log entry belongs to.

action_type: AuditLogType

The type of action that was performed.

reason: str | None

The reason for the action, if provided.

user_id: int | None

The ID of the user who performed the action, if available.

property created_at: datetime

The datetime of the snowflake.

id: int

The ID of the snowflake.

target_id: int | None

The ID of the target of the action, if available.

options: dict

Additional options related to the action, if any.

changes: list[AuditChange]

A list of changes made in this audit log entry.

property user: User | PartialUser | None

The user object of the audit log if available.

property target: Snowflake | None

The target object of the audit log.

The Snowflake can be a PartialChannel, User, PartialRole, etc

get_change(key) AuditChange[Any] | None

Returns the change with the given key, if it exists.

When called with a known string literal (e.g. color), the return type is narrowed via overloads so that old_value and new_value carry the correct type (e.g. AuditChange[Colour]). Unknown keys fall back to AuditChange[Any].

Parameters:

key (str) – The key of the change to retrieve.

Return type:

Optional[AuditChange[Any]]

Returns:

The change with the given key, or None if no such change exists.