Package discord4j.core.object.audit
Class AuditLogEntry
java.lang.Object
discord4j.core.object.audit.AuditLogEntry
- All Implemented Interfaces:
DiscordObject
,Entity
A single administrative action or event, that can be recorded by an
AuditLogPart
if it didn't originate from
a gateway event.
Use getActionType()
to determine what kind of action occurred, and then getChange(ChangeKey)
to
get information about what changed. For example,
if (entry.getActionType() == CHANNEL_UPDATE) {
entry.getChange(ChangeKey.NAME)
.flatMap(AuditLogChange::getCurrentValue)
.ifPresent(newName -> System.out.println("The channel's new name is " + newName));
}
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The maximum amount of characters that can be in an audit log reason. -
Constructor Summary
ConstructorDescriptionAuditLogEntry
(GatewayDiscordClient gateway, discord4j.discordjson.json.AuditLogEntryData data) -
Method Summary
Modifier and TypeMethodDescriptionGets type of action that occurred.<T> Optional<AuditLogChange<T>>
Gets a change that was recorded by this entry.Returns theGatewayDiscordClient
that created this object.discord4j.discordjson.json.AuditLogEntryData
getData()
Gets the data of the audit log entry.getId()
Gets the Snowflake that uniquely identifies this entity.<T> Optional<T>
Gets one of the optional extra pieces of information recorded by an audit log entry.Gets theaudit log part
that this entry belongs to.Gets the reason for the change, if present.Gets the user who made the changes, if present.Gets the ID of the user who made the changes, if present.Gets the id of the affected entity (webhook, user, role, etc.), if present.toString()
-
Field Details
-
MAX_REASON_LENGTH
public static final int MAX_REASON_LENGTHThe maximum amount of characters that can be in an audit log reason.- See Also:
-
-
Constructor Details
-
AuditLogEntry
public AuditLogEntry(GatewayDiscordClient gateway, discord4j.discordjson.json.AuditLogEntryData data)
-
-
Method Details
-
getData
public discord4j.discordjson.json.AuditLogEntryData getData()Gets the data of the audit log entry.- Returns:
- The data of the audit log entry.
-
getTargetId
Gets the id of the affected entity (webhook, user, role, etc.), if present.- Returns:
- The id of the affected entity (webhook, user, role, etc.), if present.
-
getResponsibleUserId
Gets the ID of the user who made the changes, if present.- Returns:
- The ID of the user who made the changes, if present.
-
getResponsibleUser
Gets the user who made the changes, if present.- Returns:
- The user who made the changes, if present.
- Throws:
NoSuchElementException
- ifgetParent()
does not contain thegetResponsibleUserId()
or if this entry was created from a gateway event.
-
getReason
Gets the reason for the change, if present.- Returns:
- The reason for the change, if present.
-
getActionType
Gets type of action that occurred.- Returns:
- The type of action that occurred.
-
getChange
Gets a change that was recorded by this entry. The possible changes correspond to eachChangeKey
.- Type Parameters:
T
- The type of the audit log change key.- Parameters:
changeKey
- The audit log change key.- Returns:
- The change made to the target, if present.
-
getOption
Gets one of the optional extra pieces of information recorded by an audit log entry. The possible options correspond to eachOptionKey
.- Type Parameters:
T
- The type of the option key.- Parameters:
optionKey
- The option key.- Returns:
- The option, if present.
-
getParent
Gets theaudit log part
that this entry belongs to.- Returns:
- The audit log part that this entry belongs to, or
null
if the entry originated from aAuditLogEntryCreateEvent
-
getId
Description copied from interface:Entity
Gets the Snowflake that uniquely identifies this entity. -
getClient
Description copied from interface:DiscordObject
Returns theGatewayDiscordClient
that created this object. Methods in it are exclusively based on the entity cache orStore
in use. Refer to callinggetClient().rest()
to access aDiscordClient
that is capable of requesting entities directly from the REST API.- Specified by:
getClient
in interfaceDiscordObject
- Returns:
- The
GatewayDiscordClient
associated to this object.
-
toString
-