Class AuditLogPaginationAction
- java.lang.Object
-
- net.dv8tion.jda.core.requests.RestAction<java.util.List<T>>
-
- net.dv8tion.jda.core.requests.restaction.pagination.PaginationAction<AuditLogEntry,AuditLogPaginationAction>
-
- net.dv8tion.jda.core.requests.restaction.pagination.AuditLogPaginationAction
-
- All Implemented Interfaces:
java.lang.Iterable<AuditLogEntry>
public class AuditLogPaginationAction extends PaginationAction<AuditLogEntry,AuditLogPaginationAction>
PaginationAction
that paginates the endpointRoute.Guilds.GET_AUDIT_LOGS
.Must provide not-null
Guild
to compile a valid guild audit logs pagination routeLimits
Minimum - 1
Maximum - 100Example
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.dv8tion.jda.core.requests.restaction.pagination.PaginationAction
PaginationAction.PaginationIterator
-
Nested classes/interfaces inherited from class net.dv8tion.jda.core.requests.RestAction
RestAction.EmptyRestAction<T>
-
-
Field Summary
-
Fields inherited from class net.dv8tion.jda.core.requests.RestAction
DEFAULT_FAILURE, DEFAULT_SUCCESS, LOG
-
-
Constructor Summary
Constructors Constructor Description AuditLogPaginationAction(Guild guild)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Guild
getGuild()
The current targetGuild
for this AuditLogPaginationAction.AuditLogPaginationAction
type(ActionType type)
Filters retrieved entities by the specifiedActionType
AuditLogPaginationAction
user(long userId)
Filters retrieved entities by the specifiedUser
id.AuditLogPaginationAction
user(java.lang.String userId)
Filters retrieved entities by the specifiedUser
id.AuditLogPaginationAction
user(User user)
Filters retrieved entities by the specifiedUser
.-
Methods inherited from class net.dv8tion.jda.core.requests.restaction.pagination.PaginationAction
cache, cacheSize, forEachAsync, forEachAsync, forEachRemaining, forEachRemainingAsync, forEachRemainingAsync, getCached, getFirst, getLast, getLimit, getMaxLimit, getMinLimit, isCacheEnabled, isEmpty, iterator, limit, parallelStream, setCheck, spliterator, stream, takeAsync, takeRemainingAsync
-
Methods inherited from class net.dv8tion.jda.core.requests.RestAction
complete, complete, completeAfter, getJDA, isPassContext, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, setPassContext, submit, submit, submitAfter, submitAfter
-
-
-
-
Constructor Detail
-
AuditLogPaginationAction
public AuditLogPaginationAction(Guild guild)
-
-
Method Detail
-
type
public AuditLogPaginationAction type(ActionType type)
Filters retrieved entities by the specifiedActionType
- Parameters:
type
-ActionType
used to filter, ornull
to remove type filtering- Returns:
- The current AuditLogPaginationAction for chaining convenience
-
user
public AuditLogPaginationAction user(User user)
Filters retrieved entities by the specifiedUser
.
This specified the action issuer and not the target of an action. (Targets need not be users)- Parameters:
user
-User
used to filter, ornull
to remove user filtering- Returns:
- The current AuditLogPaginationAction for chaining convenience
-
user
public AuditLogPaginationAction user(java.lang.String userId)
Filters retrieved entities by the specifiedUser
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, ornull
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 specifiedUser
id.- Parameters:
userId
-User
id used to filter, ornull
to remove user filtering- Returns:
- The current AuditLogPaginationAction for chaining convenience
-
-