Interface MessagePaginationAction
-
- All Superinterfaces:
java.lang.Iterable<Message>
,PaginationAction<Message,MessagePaginationAction>
,RestAction<java.util.List<Message>>
public interface MessagePaginationAction extends PaginationAction<Message,MessagePaginationAction>
PaginationAction
that paginates the message history 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
MessageChannel
to compile a valid pagination route.Limits:
Minimum - 1
Maximum - 100Example
/** * Iterates messages in an async stream and stops once the limit has been reached. */ public static void onEachMessageAsync(MessageChannel channel, Consumer<Message> consumer, int limit) { if (limit< 1) return; MessagePaginationAction action = channel.getIterableHistory(); AtomicInteger counter = new AtomicInteger(limit); action.forEachAsync( (message)-> { consumer.accept(message); // if false the iteration is terminated; else it continues return counter.decrementAndGet() == 0; }); }
- Since:
- 3.1
- See Also:
MessageChannel.getIterableHistory()
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.requests.restaction.pagination.PaginationAction
PaginationAction.PaginationIterator<E>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description MessageChannel
getChannel()
The targetedMessageChannel
default ChannelType
getType()
TheChannelType
of the targetedMessageChannel
.-
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 Detail
-
getType
@Nonnull default ChannelType getType()
TheChannelType
of the targetedMessageChannel
.- Returns:
ChannelType
-
getChannel
@Nonnull MessageChannel getChannel()
The targetedMessageChannel
- Returns:
- The MessageChannel instance
-
-