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 - 1Maximum - 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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.requests.restaction.pagination.PaginationAction
PaginationAction.PaginationIterator<E>
-
Method Summary
Modifier and TypeMethodDescriptiongetGuild()
The current targetGuild
for this AuditLogPaginationAction.type
(ActionType type) Filters retrieved entities by the specifiedActionType
user
(long userId) Filters retrieved entities by the specifiedUser
id.Filters retrieved entities by the specifiedUser
id.Filters retrieved entities by the specifiedUser
.Methods inherited from interface net.dv8tion.jda.api.requests.restaction.pagination.PaginationAction
cache, cacheSize, deadline, forEachAsync, forEachAsync, forEachRemaining, forEachRemainingAsync, forEachRemainingAsync, getCached, getFirst, getLast, getLastKey, getLimit, getMaxLimit, getMinLimit, isCacheEnabled, isEmpty, iterator, limit, parallelStream, setCheck, skipTo, spliterator, stream, takeAsync, takeRemainingAsync, takeUntilAsync, takeUntilAsync, takeWhileAsync, takeWhileAsync, timeout
Methods inherited from interface net.dv8tion.jda.api.requests.RestAction
addCheck, and, and, complete, complete, completeAfter, delay, delay, delay, delay, flatMap, flatMap, getCheck, getJDA, map, mapToResult, onErrorFlatMap, onErrorFlatMap, onErrorMap, onErrorMap, queue, queue, queue, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, queueAfter, submit, submit, submitAfter, submitAfter, zip
-
Method Details
-
getGuild
The current targetGuild
for this AuditLogPaginationAction.- Returns:
- The never-null target Guild
-
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
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
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:
IllegalArgumentException
- If the provided userId is not valid
-
user
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
-