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.
- 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. SeeAuditLogAction
for which actions have this field filled out.- Type:
Any
- category
The category of the action, if applicable.
- Type:
Optional[
AuditLogActionCategory
]
AuditLogChanges
- class discord.AuditLogChanges
An audit log change set.
- before
The old value. The attribute has the type of
AuditLogDiff
.Depending on the
AuditLogActionCategory
retrieved bycategory
, the data retrieved by this attribute differs:
- after
The new value. The attribute has the type of
AuditLogDiff
.Depending on the
AuditLogActionCategory
retrieved bycategory
, the data retrieved by this attribute differs:
AuditLogDiff
- afk_channel
- afk_timeout
- allow
- avatar
- bitrate
- channel
- code
- color
- colour
- deaf
- default_message_notifications
- default_notifications
- deny
- explicit_content_filter
- hoist
- icon
- id
- inviter
- max_age
- max_uses
- mentionable
- mfa_level
- mute
- name
- nick
- overwrites
- owner
- permissions
- position
- region
- roles
- slowmode_delay
- splash
- system_channel
- temporary
- topic
- type
- uses
- vanity_url_code
- verification_level
- widget_channel
- widget_enabled
- 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.
- icon
A guild’s icon hash. See also
Guild.icon
.- Type:
- splash
The guild’s invite splash hash. See also
Guild.splash
.- Type:
- owner
The guild’s owner. See also
Guild.owner
- 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:
- mfa_level
The guild’s MFA level. See
Guild.mfa_level
.- Type:
- 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:
- default_notifications
The guild’s default notification level.
See also
Guild.default_notifications
.- Type:
- explicit_content_filter
The guild’s content filter.
See also
Guild.explicit_content_filter
.- Type:
- vanity_url_code
The guild’s vanity URL.
See also
Guild.vanity_invite()
andGuild.edit()
.- Type:
- position
The position of a
Role
orabc.GuildChannel
.- Type:
- 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 either0
to indicate a text channel or1
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'
.
- topic
The topic of a
TextChannel
.See also
TextChannel.topic
.- Type:
- bitrate
The bitrate of a
VoiceChannel
.See also
VoiceChannel.bitrate
.- Type:
- 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
orUser
orRole
. If this object is not found then it is aObject
with an ID being filled and atype
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.
- 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:
- mute
Whether the member is being server muted.
See also
VoiceState.mute
.- Type:
- permissions
The permissions of a role.
See also
Role.permissions
.- Type:
- colour
- color
The colour of a role.
See also
Role.colour
- Type:
- hoist
Whether the role is being hoisted or not.
See also
Role.hoist
- Type:
- mentionable
Whether the role is mentionable or not.
See also
Role.mentionable
- Type:
- code
The invite’s code.
See also
Invite.code
- Type:
- 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:
- max_uses
The invite’s max uses.
See also
Invite.max_uses
.- Type:
- uses
The invite’s current uses.
See also
Invite.uses
.- Type:
- max_age
The invite’s max age in seconds.
See also
Invite.max_age
.- Type:
- temporary
If the invite is a temporary invite.
See also
Invite.temporary
.- Type:
- avatar
The avatar hash of a member.
See also
User.avatar
.- Type:
- slowmode_delay
The number of seconds members have to wait before sending another message in the channel.
See also
TextChannel.slowmode_delay
.- Type: