Audit Log Data

Working with Guild.audit_logs() is a complicated process with a lot of machinery involved. The library attempts to make it easy to use and friendly. In order to accomplish this goal, it must make use of a couple of data classes that aid in this goal.

AuditLogEntry

class discord.AuditLogEntry(*, users, data, guild)

Bases: Hashable

Represents an Audit Log entry.

You retrieve these via Guild.audit_logs().

x == y

Checks if two entries are equal.

x != y

Checks if two entries are not equal.

hash(x)

Returns the entry’s hash.

Changed in version 1.7: Audit log entries are now comparable and hashable.

action

The action that was done.

Type:

AuditLogAction

user

The user who initiated this action. Usually a Member, unless gone then it’s a User.

Type:

abc.User

id

The entry ID.

Type:

int

target

The target that got changed. The exact type of this depends on the action being done.

Type:

Any

reason

The reason this action was done.

Type:

Optional[str]

extra

Extra information that this entry has that might be useful. For most actions, this is None. However in some cases it contains extra information. See AuditLogAction for which actions have this field filled out.

Type:

Any

created_at

Returns the entry’s creation time in UTC.

Type:

datetime.datetime

category

The category of the action, if applicable.

Type:

Optional[AuditLogActionCategory]

changes

The list of changes this entry has.

Type:

AuditLogChanges

before

The target’s prior state.

Type:

AuditLogDiff

after

The target’s subsequent state.

Type:

AuditLogDiff

AuditLogChanges

Attributes
class discord.AuditLogChanges

An audit log change set.

before

The old value. The attribute has the type of AuditLogDiff.

Depending on the AuditLogActionCategory retrieved by category, the data retrieved by this attribute differs:

Category

Description

create

All attributes are set to None.

delete

All attributes are set the value before deletion.

update

All attributes are set the value before updating.

None

No attributes are set.

after

The new value. The attribute has the type of AuditLogDiff.

Depending on the AuditLogActionCategory retrieved by category, the data retrieved by this attribute differs:

Category

Description

create

All attributes are set to the created value

delete

All attributes are set to None

update

All attributes are set the value after updating.

None

No attributes are set.

AuditLogDiff

class discord.AuditLogDiff

Represents an audit log “change” object. A change object has dynamic attributes that depend on the type of action being done. Certain actions map to certain attributes being set.

Note that accessing an attribute that does not match the specified action will lead to an attribute error.

To get a list of attributes that have been set, you can iterate over them. To see a list of all possible attributes that could be set based on the action being done, check the documentation for AuditLogAction, otherwise check the documentation below for all attributes that are possible.

iter(diff)

Returns an iterator over (attribute, value) tuple of this diff.

name

A name of something.

Type:

str

icon

A guild’s icon hash. See also Guild.icon.

Type:

str

splash

The guild’s invite splash hash. See also Guild.splash.

Type:

str

owner

The guild’s owner. See also Guild.owner

Type:

Union[Member, User]

region

The guild’s voice region. See also Guild.region.

Type:

VoiceRegion

afk_channel

The guild’s AFK channel.

If this could not be found, then it falls back to a Object with the ID being set.

See Guild.afk_channel.

Type:

Union[VoiceChannel, Object]

system_channel

The guild’s system channel.

If this could not be found, then it falls back to a Object with the ID being set.

See Guild.system_channel.

Type:

Union[TextChannel, Object]

afk_timeout

The guild’s AFK timeout. See Guild.afk_timeout.

Type:

int

mfa_level

The guild’s MFA level. See Guild.mfa_level.

Type:

int

widget_enabled

The guild’s widget has been enabled or disabled.

Type:

bool

widget_channel

The widget’s channel.

If this could not be found then it falls back to a Object with the ID being set.

Type:

Union[TextChannel, Object]

verification_level

The guild’s verification level.

See also Guild.verification_level.

Type:

VerificationLevel

default_notifications

The guild’s default notification level.

See also Guild.default_notifications.

Type:

NotificationLevel

explicit_content_filter

The guild’s content filter.

See also Guild.explicit_content_filter.

Type:

ContentFilter

default_message_notifications

The guild’s default message notification setting.

Type:

int

vanity_url_code

The guild’s vanity URL.

See also Guild.vanity_invite() and Guild.edit().

Type:

str

position

The position of a Role or abc.GuildChannel.

Type:

int

type

The type of channel or channel permission overwrite.

If the type is an int, then it is a type of channel which can be either 0 to indicate a text channel or 1 to indicate a voice channel.

If the type is a str, then it is a type of permission overwrite which can be either 'role' or 'member'.

Type:

Union[int, str]

topic

The topic of a TextChannel.

See also TextChannel.topic.

Type:

str

bitrate

The bitrate of a VoiceChannel.

See also VoiceChannel.bitrate.

Type:

int

overwrites

A list of permission overwrite tuples that represents a target and a PermissionOverwrite for said target.

The first element is the object being targeted, which can either be a Member or User or Role. If this object is not found then it is a Object with an ID being filled and a type attribute set to either 'role' or 'member' to help decide what type of ID it is.

Type:

List[Tuple[target, PermissionOverwrite]]

roles

A list of roles being added or removed from a member.

If a role is not found then it is a Object with the ID and name being filled in.

Type:

List[Union[Role, Object]]

nick

The nickname of a member.

See also Member.nick

Type:

Optional[str]

deaf

Whether the member is being server deafened.

See also VoiceState.deaf.

Type:

bool

mute

Whether the member is being server muted.

See also VoiceState.mute.

Type:

bool

permissions

The permissions of a role.

See also Role.permissions.

Type:

Permissions

colour
color

The colour of a role.

See also Role.colour

Type:

Colour

hoist

Whether the role is being hoisted or not.

See also Role.hoist

Type:

bool

mentionable

Whether the role is mentionable or not.

See also Role.mentionable

Type:

bool

code

The invite’s code.

See also Invite.code

Type:

str

channel

A guild channel.

If the channel is not found then it is a Object with the ID being set. In some cases the channel name is also set.

Type:

Union[abc.GuildChannel, Object]

inviter

The user who created the invite.

See also Invite.inviter.

Type:

User

max_uses

The invite’s max uses.

See also Invite.max_uses.

Type:

int

uses

The invite’s current uses.

See also Invite.uses.

Type:

int

max_age

The invite’s max age in seconds.

See also Invite.max_age.

Type:

int

temporary

If the invite is a temporary invite.

See also Invite.temporary.

Type:

bool

allow
deny

The permissions being allowed or denied.

Type:

Permissions

id

The ID of the object being changed.

Type:

int

avatar

The avatar hash of a member.

See also User.avatar.

Type:

str

slowmode_delay

The number of seconds members have to wait before sending another message in the channel.

See also TextChannel.slowmode_delay.

Type:

int