Java Code Examples for net.dv8tion.jda.api.requests.GatewayIntent#getIntents()

The following examples show how to use net.dv8tion.jda.api.requests.GatewayIntent#getIntents() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultShardManagerBuilder.java    From JDA with Apache License 2.0 5 votes vote down vote up
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 + "!");
    }
}
 
Example 2
Source File: JDABuilder.java    From JDA with Apache License 2.0 5 votes vote down vote up
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)
        JDAImpl.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 JDABuilder",
            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 + "!");
    }
}
 
Example 3
Source File: DefaultShardManager.java    From JDA with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public EnumSet<GatewayIntent> getGatewayIntents()
{
    return GatewayIntent.getIntents(shardingConfig.getIntents());
}
 
Example 4
Source File: JDAImpl.java    From JDA with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public EnumSet<GatewayIntent> getGatewayIntents()
{
    return GatewayIntent.getIntents(client.getGatewayIntents());
}