Interface AuditLogPaginationAction
- All Superinterfaces:
Iterable<AuditLogEntry>
,PaginationAction<AuditLogEntry,
,AuditLogPaginationAction> RestAction<@Unmodifiable 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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.requests.restaction.pagination.PaginationAction
PaginationAction.PaginationIterator<E>, PaginationAction.PaginationOrder
-
Method Summary
Modifier and TypeMethodDescriptiongetGuild()
The current targetGuild
for this AuditLogPaginationAction.type
(ActionType type) Filters retrieved entities by the specifiedActionType
user
(UserSnowflake user) Filters retrieved entities by the specifiedUserSnowflake
.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, getOrder, getSupportedOrders, isCacheEnabled, isEmpty, iterator, limit, order, parallelStream, reverse, 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, onSuccess, 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 specifiedUserSnowflake
.
This specified the action issuer and not the target of an action. (Targets need not be users)- Parameters:
user
- TheUserSnowflake
used to filter ornull
to remove user filtering. This can be a member or user instance orUser.fromId(long)
.- Returns:
- The current AuditLogPaginationAction for chaining convenience
-