Class AuditLogPaginationAction

  • All Implemented Interfaces:
    java.lang.Iterable<AuditLogEntry>

    public class AuditLogPaginationAction
    extends PaginationAction<AuditLogEntry,​AuditLogPaginationAction>
    PaginationAction that paginates the endpoint Route.Guilds.GET_AUDIT_LOGS.

    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().getAuditLogs();
             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
    • Constructor Detail

      • AuditLogPaginationAction

        public AuditLogPaginationAction​(Guild guild)
    • Method Detail

      • type

        public AuditLogPaginationAction type​(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

        public AuditLogPaginationAction user​(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

        public AuditLogPaginationAction user​(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

        public 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
      • getGuild

        public Guild getGuild()
        The current target Guild for this AuditLogPaginationAction.
        Returns:
        The never-null target Guild