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.

class discord.AuditLogEntry(*, users, data, guild)[source]#

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:

Optional[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.

category#

The category of the action, if applicable.

changes#

The list of changes this entry has.

before#

The target’s prior state.

after#

The target’s subsequent state.

Attributes
class discord.AuditLogChanges[source]#

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.

class discord.AuditLogDiff[source]#

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. See also Guild.icon.

Type:

Asset

splash#

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

Type:

Asset

discovery_splash#

The guild’s discovery splash. See also Guild.discovery_splash.

Type:

Asset

banner#

The guild’s banner. See also Guild.banner.

Type:

Asset

owner#

The guild’s owner. See also Guild.owner

Type:

Union[Member, User]

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]

rules_channel#

The guild’s rules channel.

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

See Guild.rules_channel.

Type:

Union[TextChannel, Object]

public_updates_channel#

The guild’s public updates channel.

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

See Guild.public_updates_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 sticker.

Type:

Union[ChannelType, StickerType]

topic#

The topic of a TextChannel or StageChannel.

See also TextChannel.topic or StageChannel.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]]

privacy_level#

The privacy level of the stage instance or scheduled event.

Type:

Union[StagePrivacyLevel, ScheduledEventPrivacyLevel]

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:

Optional[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 of a member.

See also User.avatar.

Type:

Asset

slowmode_delay#

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

See also TextChannel.slowmode_delay.

Type:

int

rtc_region#

The region for the voice channel’s voice communication. A value of None indicates automatic voice region detection.

See also VoiceChannel.rtc_region.

Type:

VoiceRegion

video_quality_mode#

The camera video quality for the voice channel’s participants.

See also VoiceChannel.video_quality_mode.

Type:

VideoQualityMode

format_type#

The format type of a sticker being changed.

See also GuildSticker.format

Type:

StickerFormatType

emoji#

The name of the emoji that represents a sticker being changed.

See also GuildSticker.emoji

Type:

str

description#

The description of a sticker being changed.

See also GuildSticker.description

Type:

str

available#

The availability of a sticker being changed.

See also GuildSticker.available

Type:

bool

archived#

The thread is now archived.

Type:

bool

locked#

The thread is being locked or unlocked.

Type:

bool

auto_archive_duration#

The thread’s auto archive duration being changed.

See also Thread.auto_archive_duration

Type:

int

default_auto_archive_duration#

The default auto archive duration for newly created threads being changed.

Type:

int

invitable#

Non-moderators can now add other non-moderators to this thread.

Type:

bool

command_id#

This command’s permissions were updated.

Type:

int

status#

The voice channel status of a VoiceChannel.

See also VoiceChannel.status.

Type:

str