Interface AuditLogPaginationAction

All Superinterfaces:
Iterable<AuditLogEntry>, PaginationAction<AuditLogEntry, AuditLogPaginationAction>, RestAction<List<AuditLogEntry>>

public interface AuditLogPaginationAction extends PaginationAction<AuditLogEntry, AuditLogPaginationAction>
PaginationAction that paginates the audit logs endpoint.
Note that this implementation is not considered thread-safe as modifications to the cache are not done with a lock. Calling methods on this class from multiple threads is not recommended.

Must provide not-null Guild to compile a valid guild audit logs pagination route

Limits
Minimum - 1
Maximum - 100

Example

public class Listener extends ListenerAdapter
{
    @Override
    public void onRoleCreate(RoleCreateEvent event)
    {
        List<TextChannel> channels = event.getGuild().getTextChannelsByName("logs", true);
        if (channels.isEmpty()) return; // no log channel
        TextChannel channel = channels.get(0); // get first match

        AuditLogPaginationAction auditLogs = event.getGuild().retrieveAuditLogs();
        auditLogs.type(ActionType.ROLE_CREATE); // only take ROLE_CREATE type
        auditLogs.limit(1); // take first
        auditLogs.queue( (entries) ->
        {
            // callback has a list, this may be empty due to race conditions
            if (entries.isEmpty()) return;
            AuditLogEntry entry = entries.get(0);
            channel.sendMessageFormat("A role has been updated by %#s!", entry.getUser()).queue();
        });
    }
}
Since:
3.2
See Also:
  • Method Details

    • getGuild

      @Nonnull Guild getGuild()
      The current target Guild for this AuditLogPaginationAction.
      Returns:
      The never-null target Guild
    • type

      @Nonnull @CheckReturnValue AuditLogPaginationAction type(@Nullable ActionType type)
      Filters retrieved entities by the specified ActionType
      Parameters:
      type - ActionType used to filter, or null to remove type filtering
      Returns:
      The current AuditLogPaginationAction for chaining convenience
    • user

      @Nonnull @CheckReturnValue AuditLogPaginationAction user(@Nullable UserSnowflake user)
      Filters retrieved entities by the specified UserSnowflake.
      This specified the action issuer and not the target of an action. (Targets need not be users)
      Parameters:
      user - The UserSnowflake used to filter or null to remove user filtering. This can be a member or user instance or User.fromId(long).
      Returns:
      The current AuditLogPaginationAction for chaining convenience