Interface MemberCachePolicy

    • Field Detail

      • ALL

        static final MemberCachePolicy ALL
        Enable all member caching.

        Not recommended without GUILD_MEMBERS intent enabled. The api will only send the guild member leave events when this intent is enabled. Without those events the members will stay in cache indefinitely.

      • ONLINE

        static final MemberCachePolicy ONLINE
        Cache online/idle/dnd users.
        Requires GatewayIntent.GUILD_PRESENCES and CacheFlag.ONLINE_STATUS to be enabled.

        This cannot cache online members immediately when they come online, due to discord limitations. Discord only sends presence information without member details so the member will be cached once they become active.

        Not recommended without GUILD_MEMBERS intent enabled. The api will only send the guild member leave events when this intent is enabled. Without those events the members will stay in cache indefinitely.

      • PENDING

        @Incubating
        static final MemberCachePolicy PENDING
        Caches members who haven't passed Membership Screening.

        Not recommended without GUILD_MEMBERS intent enabled. The api will only send the guild member update events when this intent is enabled. Without those events the members will stay in cache indefinitely.

        Incubating:
        Discord is still trying to figure this out
    • Method Detail

      • cacheMember

        boolean cacheMember​(@Nonnull
                            Member member)
        Idempotent (ideally pure) function which decided whether to cache the provided member or not.
        The function should avoid throwing any exceptions or blocking.
        Parameters:
        member - The member
        Returns:
        True, if the member should be cached
      • or

        @Nonnull
        default MemberCachePolicy or​(@Nonnull
                                     MemberCachePolicy policy)
        Convenience method to concatenate another policy.
        This is identical to (member) -> policy1.cacheMember(member) || policy2.cacheMember(member).
        Parameters:
        policy - The policy to concat
        Returns:
        New policy which combines both using a logical OR
        Throws:
        java.lang.IllegalArgumentException - If the provided policy is null
      • and

        @Nonnull
        default MemberCachePolicy and​(@Nonnull
                                      MemberCachePolicy policy)
        Convenience method to require another policy.
        This is identical to (member) -> policy1.cacheMember(member) && policy2.cacheMember(member).
        Parameters:
        policy - The policy to require in addition to this one
        Returns:
        New policy which combines both using a logical AND
        Throws:
        java.lang.IllegalArgumentException - If the provided policy is null
      • any

        @Nonnull
        static MemberCachePolicy any​(@Nonnull
                                     MemberCachePolicy policy,
                                     @Nonnull
                                     MemberCachePolicy... policies)
        Composes a policy by concatenating multiple other policies.
        This is logically identical to policy1 || policy2 || policy3 || ... || policyN.
        Parameters:
        policy - The first policy
        policies - The other policies
        Returns:
        New policy which combines all provided polices using a logical OR
      • all

        @Nonnull
        static MemberCachePolicy all​(@Nonnull
                                     MemberCachePolicy policy,
                                     @Nonnull
                                     MemberCachePolicy... policies)
        Composes a policy which requires multiple other policies.
        This is logically identical to policy1 && policy2 && policy3 && ... && policyN.
        Parameters:
        policy - The first policy
        policies - The other policies
        Returns:
        New policy which combines all provided polices using a logical AND