Interface ThreadChannelPaginationAction
- All Superinterfaces:
Iterable<ThreadChannel>,PaginationAction<ThreadChannel,,ThreadChannelPaginationAction> RestAction<@Unmodifiable 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 - 1
Maximum - 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>, PaginationAction.PaginationOrder -
Method Summary
Modifier and TypeMethodDescriptionTheIThreadContainerUnionfor this action
This can also be used for casting down to more concrete types.default GuildgetGuild()The current targetGuildfor this ThreadChannelPaginationAction.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, timeoutMethods 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
-
getChannel
TheIThreadContainerUnionfor this action
This can also be used for casting down to more concrete types.- Returns:
IThreadContainerUnion
-
getGuild
The current targetGuildfor this ThreadChannelPaginationAction.- Returns:
- The never-null target Guild
-