Interface ThreadChannelPaginationAction
- All Superinterfaces:
Iterable<ThreadChannel>
,PaginationAction<ThreadChannel,
,ThreadChannelPaginationAction> RestAction<List<ThreadChannel>>
public interface ThreadChannelPaginationAction
extends PaginationAction<ThreadChannel,ThreadChannelPaginationAction>
PaginationAction
that paginates the thread members 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 IThreadContainer
to compile a valid
pagination route.
Limits:
Minimum - 1Maximum - 100
Example
// Clean up all private threads older than 2 weeks
public static void cleanupPrivateThreads(TextChannel channel) {
// get 2-week offset
long 2WeekAgoTimestamp = System.currentTimeMillis() - (14 * 24 * 60 * 60 * 1000);
// get paginator
ThreadChannelPaginationAction threads = channel.retrieveArchivedPrivateThreadChannels();
// remove each thread older than 2 weeks
threads.forEachAsync((thread) ->
long threadArchiveTimestamp = thread.getTimeArchiveInfoLastModified().toInstant().toEpochMilli();
if (threadArchiveTimestamp < 2WeeksAgoTimestamp) {
thread.delete().reason("Cleaning up old private threads").queue();
}
);
}
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.requests.restaction.pagination.PaginationAction
PaginationAction.PaginationIterator<E>
-
Method Summary
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
-
getChannel
-
getGuild
The current targetGuild
for this ThreadChannelPaginationAction.- Returns:
- The never-null target Guild
-