Package discord4j.core.object.audit
Class AuditLogEntry
- java.lang.Object
-
- discord4j.core.object.audit.AuditLogEntry
-
- All Implemented Interfaces:
DiscordObject,Entity
public class AuditLogEntry extends Object implements Entity
A single action recorded by anAuditLogPart.Use
getActionType()to determine what kind of action occurred, and thengetChange(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
Fields Modifier and Type Field Description static intMAX_REASON_LENGTHThe maximum amount of characters that can be in an audit log reason.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ActionTypegetActionType()Gets type of action that occurred.<T> Optional<AuditLogChange<T>>getChange(ChangeKey<T> changeKey)Gets a change that was recorded by this entry.GatewayDiscordClientgetClient()Returns theGatewayDiscordClientthat created this object.discord4j.discordjson.json.AuditLogEntryDatagetData()Gets the data of the audit log entry.SnowflakegetId()Gets the Snowflake that uniquely identifies this entity.<T> Optional<T>getOption(OptionKey<T> optionKey)Gets one of the optional extra pieces of information recorded by an audit log entry.AuditLogPartgetParent()Gets theaudit log partthat this entry belongs to.Optional<String>getReason()Gets the reason for the change, if present.Optional<User>getResponsibleUser()Gets the user who made the changes, if present.Optional<Snowflake>getResponsibleUserId()Gets the ID of the user who made the changes, if present.Optional<Snowflake>getTargetId()Gets the id of the affected entity (webhook, user, role, etc.), if present.StringtoString()
-
-
-
Field Detail
-
MAX_REASON_LENGTH
public static final int MAX_REASON_LENGTH
The maximum amount of characters that can be in an audit log reason.- See Also:
- Constant Field Values
-
-
Method Detail
-
getData
public discord4j.discordjson.json.AuditLogEntryData getData()
Gets the data of the audit log entry.- Returns:
- The data of the audit log entry.
-
getTargetId
public Optional<Snowflake> 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
public Optional<Snowflake> 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
public Optional<User> getResponsibleUser()
Gets the user who made the changes, if present.- Returns:
- The user who made the changes, if present.
-
getReason
public Optional<String> getReason()
Gets the reason for the change, if present.- Returns:
- The reason for the change, if present.
-
getActionType
public ActionType getActionType()
Gets type of action that occurred.- Returns:
- The type of action that occurred.
-
getChange
public <T> Optional<AuditLogChange<T>> getChange(ChangeKey<T> changeKey)
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
public <T> Optional<T> getOption(OptionKey<T> optionKey)
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
public AuditLogPart getParent()
Gets theaudit log partthat this entry belongs to.- Returns:
- The audit log part that this entry belongs to.
-
getId
public Snowflake getId()
Description copied from interface:EntityGets the Snowflake that uniquely identifies this entity.
-
getClient
public GatewayDiscordClient getClient()
Description copied from interface:DiscordObjectReturns theGatewayDiscordClientthat created this object. Methods in it are exclusively based on the entity cache orStorein use. Refer to callinggetClient().rest()to access aDiscordClientthat is capable of requesting entities directly from the REST API.- Specified by:
getClientin interfaceDiscordObject- Returns:
- The
GatewayDiscordClientassociated to this object.
-
-