Interface AuditLogPaginationAction

  • All Superinterfaces:
    java.lang.Iterable<AuditLogEntry>, PaginationAction<AuditLogEntry,​AuditLogPaginationAction>, RestAction<java.util.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:
    Guild.retrieveAuditLogs()
    • Method Detail

      • getGuild

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

        @Nonnull
        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
        AuditLogPaginationAction user​(@Nullable
                                      User user)
        Filters retrieved entities by the specified User.
        This specified the action issuer and not the target of an action. (Targets need not be users)
        Parameters:
        user - User used to filter, or null to remove user filtering
        Returns:
        The current AuditLogPaginationAction for chaining convenience
      • user

        @Nonnull
        AuditLogPaginationAction user​(@Nullable
                                      java.lang.String userId)
        Filters retrieved entities by the specified User id.
        This specified the action issuer and not the target of an action. (Targets need not be users)
        Parameters:
        userId - User id used to filter, or null to remove user filtering
        Returns:
        The current AuditLogPaginationAction for chaining convenience
        Throws:
        java.lang.IllegalArgumentException - If the provided userId is not valid
      • user

        @Nonnull
        AuditLogPaginationAction user​(long userId)
        Filters retrieved entities by the specified User id.
        Parameters:
        userId - User id used to filter, or null to remove user filtering
        Returns:
        The current AuditLogPaginationAction for chaining convenience