Search in sources :

Example 1 with ChunkingFilter

use of net.dv8tion.jda.api.utils.ChunkingFilter in project JDA by DV8FromTheWorld.

the class DefaultShardManagerBuilder method checkIntents.

private void checkIntents() {
    boolean membersIntent = (intents & GatewayIntent.GUILD_MEMBERS.getRawValue()) != 0;
    if (!membersIntent && memberCachePolicy == MemberCachePolicy.ALL)
        throw new IllegalStateException("Cannot use MemberCachePolicy.ALL without GatewayIntent.GUILD_MEMBERS enabled!");
    else if (!membersIntent && chunkingFilter != ChunkingFilter.NONE)
        DefaultShardManager.LOG.warn("Member chunking is disabled due to missing GUILD_MEMBERS intent.");
    if (!automaticallyDisabled.isEmpty()) {
        JDAImpl.LOG.warn("Automatically disabled CacheFlags due to missing intents");
        // List each missing intent
        automaticallyDisabled.stream().map(it -> "Disabled CacheFlag." + it + " (missing GatewayIntent." + it.getRequiredIntent() + ")").forEach(JDAImpl.LOG::warn);
        // Tell user how to disable this warning
        JDAImpl.LOG.warn("You can manually disable these flags to remove this warning by using disableCache({}) on your DefaultShardManagerBuilder", automaticallyDisabled.stream().map(it -> "CacheFlag." + it).collect(Collectors.joining(", ")));
        // Only print this warning once
        automaticallyDisabled.clear();
    }
    if (cacheFlags.isEmpty())
        return;
    EnumSet<GatewayIntent> providedIntents = GatewayIntent.getIntents(intents);
    for (CacheFlag flag : cacheFlags) {
        GatewayIntent intent = flag.getRequiredIntent();
        if (intent != null && !providedIntents.contains(intent))
            throw new IllegalArgumentException("Cannot use CacheFlag." + flag + " without GatewayIntent." + intent + "!");
    }
}
Also used : LoginException(javax.security.auth.login.LoginException) java.util(java.util) ShardingConfigFlag(net.dv8tion.jda.internal.utils.config.flags.ShardingConfigFlag) SessionController(net.dv8tion.jda.api.utils.SessionController) GatewayIntent(net.dv8tion.jda.api.requests.GatewayIntent) JDAImpl(net.dv8tion.jda.internal.JDAImpl) net.dv8tion.jda.internal.utils.config.sharding(net.dv8tion.jda.internal.utils.config.sharding) CacheFlag(net.dv8tion.jda.api.utils.cache.CacheFlag) Nonnull(javax.annotation.Nonnull) RestAction(net.dv8tion.jda.api.requests.RestAction) Nullable(javax.annotation.Nullable) ConfigFlag(net.dv8tion.jda.internal.utils.config.flags.ConfigFlag) IntFunction(java.util.function.IntFunction) OnlineStatus(net.dv8tion.jda.api.OnlineStatus) MemberCachePolicy(net.dv8tion.jda.api.utils.MemberCachePolicy) IAudioSendFactory(net.dv8tion.jda.api.audio.factory.IAudioSendFactory) Checks(net.dv8tion.jda.internal.utils.Checks) GatewayEncoding(net.dv8tion.jda.api.GatewayEncoding) Compression(net.dv8tion.jda.api.utils.Compression) java.util.concurrent(java.util.concurrent) Activity(net.dv8tion.jda.api.entities.Activity) Collectors(java.util.stream.Collectors) VoiceDispatchInterceptor(net.dv8tion.jda.api.hooks.VoiceDispatchInterceptor) CheckReturnValue(javax.annotation.CheckReturnValue) OkHttpClient(okhttp3.OkHttpClient) WebSocketFactory(com.neovisionaries.ws.client.WebSocketFactory) IEventManager(net.dv8tion.jda.api.hooks.IEventManager) ChunkingFilter(net.dv8tion.jda.api.utils.ChunkingFilter) CacheFlag(net.dv8tion.jda.api.utils.cache.CacheFlag) GatewayIntent(net.dv8tion.jda.api.requests.GatewayIntent)

Aggregations

WebSocketFactory (com.neovisionaries.ws.client.WebSocketFactory)1 java.util (java.util)1 java.util.concurrent (java.util.concurrent)1 IntFunction (java.util.function.IntFunction)1 Collectors (java.util.stream.Collectors)1 CheckReturnValue (javax.annotation.CheckReturnValue)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 LoginException (javax.security.auth.login.LoginException)1 GatewayEncoding (net.dv8tion.jda.api.GatewayEncoding)1 OnlineStatus (net.dv8tion.jda.api.OnlineStatus)1 IAudioSendFactory (net.dv8tion.jda.api.audio.factory.IAudioSendFactory)1 Activity (net.dv8tion.jda.api.entities.Activity)1 IEventManager (net.dv8tion.jda.api.hooks.IEventManager)1 VoiceDispatchInterceptor (net.dv8tion.jda.api.hooks.VoiceDispatchInterceptor)1 GatewayIntent (net.dv8tion.jda.api.requests.GatewayIntent)1 RestAction (net.dv8tion.jda.api.requests.RestAction)1 ChunkingFilter (net.dv8tion.jda.api.utils.ChunkingFilter)1 Compression (net.dv8tion.jda.api.utils.Compression)1 MemberCachePolicy (net.dv8tion.jda.api.utils.MemberCachePolicy)1