Package net.dv8tion.jda.api.audit
Class AuditLogEntry
- java.lang.Object
-
- net.dv8tion.jda.api.audit.AuditLogEntry
-
- All Implemented Interfaces:
ISnowflake
public class AuditLogEntry extends java.lang.Object implements ISnowflake
Single entry for anAuditLogPaginationAction.
This entry contains all options/changes and details for the action that was logged by theGuildaudit-logs.
-
-
Constructor Summary
Constructors Constructor Description AuditLogEntry(ActionType type, int rawType, long id, long targetId, net.dv8tion.jda.internal.entities.GuildImpl guild, net.dv8tion.jda.internal.entities.UserImpl user, net.dv8tion.jda.internal.entities.WebhookImpl webhook, java.lang.String reason, java.util.Map<java.lang.String,AuditLogChange> changes, java.util.Map<java.lang.String,java.lang.Object> options)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)AuditLogChangegetChangeByKey(java.lang.String key)Shortcut tolookup!getChanges().get(key)
This lookup is case-insensitive!AuditLogChangegetChangeByKey(AuditLogKey key)Shortcut tolookup!getChanges().get(key)
This lookup is case-insensitive!java.util.Map<java.lang.String,AuditLogChange>getChanges()Key-ValueMapcontaining allAuditLogChangesmade in this entry.java.util.List<AuditLogChange>getChangesForKeys(AuditLogKey... keys)Filters all changes by the specified keysGuildgetGuild()TheGuildthis audit-log entry refers tolonggetIdLong()The Snowflake id of this entity.JDAgetJDA()The corresponding JDA instance of the referring Guild<T> TgetOption(AuditLogOption option)Shortcut tolookup!getOptions().get(name)<T> TgetOptionByName(java.lang.String name)Shortcut tolookup!getOptions().get(name)
This lookup is case-insensitive!java.util.Map<java.lang.String,java.lang.Object>getOptions()Key-ValueMapcontaining all Options made in this entry.java.util.List<java.lang.Object>getOptions(AuditLogOption... options)Constructs a filtered, immutable list of options corresponding to the providedAuditLogOptions.java.lang.StringgetReason()The optional reason why this action was executed.java.lang.StringgetTargetId()The id for the target entity.longgetTargetIdLong()The id for the target entity.TargetTypegetTargetType()TheTargetTypedefining what kind of entity was targeted by this action.ActionTypegetType()TheActionTypedefining what auditable Action is referred to by this entry.intgetTypeRaw()The raw type value used to derivegetType().UsergetUser()TheUserresponsible for this action.WebhookgetWebhook()TheWebhookthat the target id of this audit-log entry refers tointhashCode()java.lang.StringtoString()-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getTimeCreated
-
-
-
-
Constructor Detail
-
AuditLogEntry
public AuditLogEntry(ActionType type, int rawType, long id, long targetId, net.dv8tion.jda.internal.entities.GuildImpl guild, net.dv8tion.jda.internal.entities.UserImpl user, net.dv8tion.jda.internal.entities.WebhookImpl webhook, java.lang.String reason, java.util.Map<java.lang.String,AuditLogChange> changes, java.util.Map<java.lang.String,java.lang.Object> options)
-
-
Method Detail
-
getIdLong
public long getIdLong()
Description copied from interface:ISnowflakeThe Snowflake id of this entity. This is unique to every entity and will never change.- Specified by:
getIdLongin interfaceISnowflake- Returns:
- Long containing the Id.
-
getTargetIdLong
public long getTargetIdLong()
The id for the target entity.
This references an entity based on theTargetTypewhich is specified bygetTargetType()!- Returns:
- The target id
-
getTargetId
@Nonnull public java.lang.String getTargetId()
The id for the target entity.
This references an entity based on theTargetTypewhich is specified bygetTargetType()!- Returns:
- The target id
-
getWebhook
@Nullable public Webhook getWebhook()
TheWebhookthat the target id of this audit-log entry refers to- Returns:
- Possibly-null Webhook instance
-
getGuild
@Nonnull public Guild getGuild()
TheGuildthis audit-log entry refers to- Returns:
- The Guild instance
-
getUser
@Nullable public User getUser()
TheUserresponsible for this action.- Returns:
- Possibly-null User instance
-
getReason
@Nullable public java.lang.String getReason()
The optional reason why this action was executed.- Returns:
- Possibly-null reason String
-
getJDA
@Nonnull public JDA getJDA()
The corresponding JDA instance of the referring Guild- Returns:
- The corresponding JDA instance
-
getChanges
@Nonnull public java.util.Map<java.lang.String,AuditLogChange> getChanges()
Key-ValueMapcontaining allAuditLogChangesmade in this entry. The keys for the returned map are case-insensitive keys defined in the regarding AuditLogChange value.
To iterate only the changes you can useMap.values()!- Returns:
- Key-Value Map of changes
-
getChangeByKey
@Nullable public AuditLogChange getChangeByKey(@Nullable AuditLogKey key)
Shortcut tolookup!getChanges().get(key)
This lookup is case-insensitive!- Parameters:
key- TheAuditLogKeyto look for- Returns:
- Possibly-null value corresponding to the specified key
-
getChangeByKey
@Nullable public AuditLogChange getChangeByKey(@Nullable java.lang.String key)
Shortcut tolookup!getChanges().get(key)
This lookup is case-insensitive!- Parameters:
key- The key to look for- Returns:
- Possibly-null value corresponding to the specified key
-
getChangesForKeys
@Nonnull public java.util.List<AuditLogChange> getChangesForKeys(@Nonnull AuditLogKey... keys)
Filters all changes by the specified keys- Parameters:
keys- VarargsAuditLogKeysto look for- Returns:
- Possibly-empty, never-null immutable list of
AuditLogChanges - Throws:
java.lang.IllegalArgumentException- If provided with null array
-
getOptions
@Nonnull public java.util.Map<java.lang.String,java.lang.Object> getOptions()
Key-ValueMapcontaining all Options made in this entry. The keys for the returned map are case-insensitive keys defined in the regarding AuditLogChange value.
To iterate only the changes you can useMap.values()!Options may include secondary targets or details that do not qualify as "change".
An example of that would be thememberoption forCHANNEL_OVERRIDE_UPDATEcontaining the user_id of aMember.- Returns:
- Key-Value Map of changes
-
getOptionByName
@Nullable public <T> T getOptionByName(@Nullable java.lang.String name)Shortcut tolookup!getOptions().get(name)
This lookup is case-insensitive!- Type Parameters:
T- The expected type for this option
Will be used for casting- Parameters:
name- The field name to look for- Returns:
- Possibly-null value corresponding to the specified key
- Throws:
java.lang.ClassCastException- If the type-cast failed for the generic type.
-
getOption
@Nullable public <T> T getOption(@Nonnull AuditLogOption option)Shortcut tolookup!getOptions().get(name)- Type Parameters:
T- The expected type for this option
Will be used for casting- Parameters:
option- TheAuditLogOption- Returns:
- Possibly-null value corresponding to the specified option constant
- Throws:
java.lang.ClassCastException- If the type-cast failed for the generic type.java.lang.IllegalArgumentException- If provided withnulloption.
-
getOptions
@Nonnull public java.util.List<java.lang.Object> getOptions(@Nonnull AuditLogOption... options)Constructs a filtered, immutable list of options corresponding to the providedAuditLogOptions.
This will exclude options withnullvalues!- Parameters:
options- The not-nullAuditLogOptionswhich will be used to gather option values viagetOption(AuditLogOption)!- Returns:
- Unmodifiable list of representative values
- Throws:
java.lang.IllegalArgumentException- If provided with null options
-
getType
@Nonnull public ActionType getType()
TheActionTypedefining what auditable Action is referred to by this entry.- Returns:
- The
ActionType
-
getTypeRaw
public int getTypeRaw()
The raw type value used to derivegetType().
This can be used when a new action type is not yet supported by JDA.- Returns:
- The raw type value
-
getTargetType
@Nonnull public TargetType getTargetType()
TheTargetTypedefining what kind of entity was targeted by this action.
Shortcut forgetType().getTargetType()- Returns:
- The
TargetType
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-