Class AuditLogEntry

java.lang.Object
net.dv8tion.jda.api.audit.AuditLogEntry
All Implemented Interfaces:
ISnowflake

public class AuditLogEntry extends Object implements ISnowflake
Single entry for an AuditLogPaginationAction.
This entry contains all options/changes and details for the action that was logged by the Guild audit-logs.
  • Constructor Details

    • AuditLogEntry

      public AuditLogEntry(ActionType type, int rawType, long id, long userId, long targetId, net.dv8tion.jda.internal.entities.GuildImpl guild, net.dv8tion.jda.internal.entities.UserImpl user, net.dv8tion.jda.internal.entities.WebhookImpl webhook, String reason, Map<String,AuditLogChange> changes, Map<String,Object> options)
  • Method Details

    • getIdLong

      public long getIdLong()
      Description copied from interface: ISnowflake
      The Snowflake id of this entity. This is unique to every entity and will never change.
      Specified by:
      getIdLong in interface ISnowflake
      Returns:
      Long containing the Id.
    • getTargetIdLong

      public long getTargetIdLong()
      The id for the target entity.
      This references an entity based on the TargetType which is specified by getTargetType()!
      Returns:
      The target id
    • getTargetId

      @Nonnull public String getTargetId()
      The id for the target entity.
      This references an entity based on the TargetType which is specified by getTargetType()!
      Returns:
      The target id
    • getWebhook

      @Nullable public Webhook getWebhook()
      The Webhook that the target id of this audit-log entry refers to
      Returns:
      Possibly-null Webhook instance
    • getGuild

      @Nonnull public Guild getGuild()
      The Guild this audit-log entry refers to
      Returns:
      The Guild instance
    • getUserIdLong

      public long getUserIdLong()
      The id for the user that executed the action.
      Returns:
      The user id
    • getUserId

      @Nonnull public String getUserId()
      The id for the user that executed the action.
      Returns:
      The user id
    • getUser

      @Nullable public User getUser()
      The User responsible for this action.

      This will not be available for GuildAuditLogEntryCreateEvent, you can use getUserIdLong() instead.

      Returns:
      Possibly-null User instance
    • getReason

      @Nullable public 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 Map<String,AuditLogChange> getChanges()
      Key-Value Map containing all AuditLogChanges 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 use Map.values()!
      Returns:
      Key-Value Map of changes
    • getChangeByKey

      @Nullable public AuditLogChange getChangeByKey(@Nullable AuditLogKey key)
      Shortcut to getChanges().get(key) lookup!
      This lookup is case-insensitive!
      Parameters:
      key - The AuditLogKey to look for
      Returns:
      Possibly-null value corresponding to the specified key
    • getChangeByKey

      @Nullable public AuditLogChange getChangeByKey(@Nullable String key)
      Shortcut to getChanges().get(key) lookup!
      This lookup is case-insensitive!
      Parameters:
      key - The key to look for
      Returns:
      Possibly-null value corresponding to the specified key
    • getChangesForKeys

      @Nonnull public List<AuditLogChange> getChangesForKeys(@Nonnull AuditLogKey... keys)
      Filters all changes by the specified keys
      Parameters:
      keys - Varargs AuditLogKeys to look for
      Returns:
      Possibly-empty, never-null immutable list of AuditLogChanges
      Throws:
      IllegalArgumentException - If provided with null array
    • getOptions

      @Nonnull public Map<String,Object> getOptions()
      Key-Value Map containing 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 use Map.values()!

      Options may include secondary targets or details that do not qualify as "change".
      An example of that would be the member option for CHANNEL_OVERRIDE_UPDATE containing the user_id of a Member.

      Returns:
      Key-Value Map of changes
    • getOptionByName

      @Nullable public <T> T getOptionByName(@Nullable String name)
      Shortcut to getOptions().get(name) lookup!
      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:
      ClassCastException - If the type-cast failed for the generic type.
    • getOption

      @Nullable public <T> T getOption(@Nonnull AuditLogOption option)
      Shortcut to getOptions().get(name) lookup!
      Type Parameters:
      T - The expected type for this option
      Will be used for casting
      Parameters:
      option - The AuditLogOption
      Returns:
      Possibly-null value corresponding to the specified option constant
      Throws:
      ClassCastException - If the type-cast failed for the generic type.
      IllegalArgumentException - If provided with null option.
    • getOptions

      @Nonnull public List<Object> getOptions(@Nonnull AuditLogOption... options)
      Constructs a filtered, immutable list of options corresponding to the provided AuditLogOptions.
      This will exclude options with null values!
      Parameters:
      options - The not-null AuditLogOptions which will be used to gather option values via getOption(AuditLogOption)!
      Returns:
      Unmodifiable list of representative values
      Throws:
      IllegalArgumentException - If provided with null options
    • getType

      @Nonnull public ActionType getType()
      The ActionType defining what auditable Action is referred to by this entry.
      Returns:
      The ActionType
    • getTypeRaw

      public int getTypeRaw()
      The raw type value used to derive getType().
      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()
      The TargetType defining what kind of entity was targeted by this action.
      Shortcut for getType().getTargetType()
      Returns:
      The TargetType
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object