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

The following examples show how to use net.dv8tion.jda.api.requests.GatewayIntent#getRaw() . 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 3 votes vote down vote up
/**
 * Configures which events will be disabled.
 * Bots which did not enable presence/member updates in the developer dashboard are required to disable {@link GatewayIntent#GUILD_PRESENCES} and {@link GatewayIntent#GUILD_MEMBERS}!
 *
 * <p>It is not recommended to disable {@link GatewayIntent#GUILD_MEMBERS GatewayIntent.GUILD_MEMBERS} when
 * using {@link MemberCachePolicy#ALL MemberCachePolicy.ALL} as the members cannot be removed from cache by a leave event without this intent.
 *
 * <p>If you disable certain intents you also have to disable related {@link CacheFlag CacheFlags}.
 * This can be achieved using {@link #disableCache(CacheFlag, CacheFlag...)}. The required intents for each
 * flag are documented in the {@link CacheFlag} enum.
 *
 * @param  intents
 *         The intents to disable, or null to disable all intents (default: none)
 *
 * @return The DefaultShardManagerBuilder instance. Useful for chaining.
 *
 * @see    #setMemberCachePolicy(MemberCachePolicy)
 *
 * @since  4.2.0
 */
@Nonnull
public DefaultShardManagerBuilder setDisabledIntents(@Nullable Collection<GatewayIntent> intents)
{
    this.intents = GatewayIntent.ALL_INTENTS;
    if (intents != null)
        this.intents &= ~GatewayIntent.getRaw(intents);
    return this;
}
 
Example 2
Source File: DefaultShardManagerBuilder.java    From JDA with Apache License 2.0 3 votes vote down vote up
/**
 * Disable the specified {@link GatewayIntent GatewayIntents}.
 * <br>This will not enable any currently unset intents.
 *
 * <p>If you disable certain intents you also have to disable related {@link CacheFlag CacheFlags}.
 * This can be achieved using {@link #disableCache(CacheFlag, CacheFlag...)}. The required intents for each
 * flag are documented in the {@link CacheFlag} enum.
 *
 * @param  intents
 *         The intents to disable
 *
 * @throws IllegalArgumentException
 *         If provided with null
 *
 * @return The DefaultShardManagerBuilder instance. Useful for chaining.
 *
 * @see    #enableIntents(Collection)
 */
@Nonnull
public DefaultShardManagerBuilder disableIntents(@Nonnull Collection<GatewayIntent> intents)
{
    Checks.noneNull(intents, "GatewayIntent");
    int raw = GatewayIntent.getRaw(intents);
    this.intents &= ~raw;
    return this;
}
 
Example 3
Source File: DefaultShardManagerBuilder.java    From JDA with Apache License 2.0 3 votes vote down vote up
/**
 * Disable the specified {@link GatewayIntent GatewayIntents}.
 * <br>This will not enable any currently unset intents.
 *
 * <p>If you disable certain intents you also have to disable related {@link CacheFlag CacheFlags}.
 * This can be achieved using {@link #disableCache(CacheFlag, CacheFlag...)}. The required intents for each
 * flag are documented in the {@link CacheFlag} enum.
 *
 * @param  intent
 *         The intent to disable
 * @param  intents
 *         Other intents to disable
 *
 * @throws IllegalArgumentException
 *         If provided with null
 *
 * @return The DefaultShardManagerBuilder instance. Useful for chaining.
 *
 * @see    #enableIntents(GatewayIntent, GatewayIntent...)
 */
@Nonnull
public DefaultShardManagerBuilder disableIntents(@Nonnull GatewayIntent intent, @Nonnull GatewayIntent... intents)
{
    Checks.notNull(intent, "GatewayIntent");
    Checks.noneNull(intents, "GatewayIntent");
    int raw = GatewayIntent.getRaw(intent, intents);
    this.intents &= ~raw;
    return this;
}
 
Example 4
Source File: DefaultShardManagerBuilder.java    From JDA with Apache License 2.0 3 votes vote down vote up
/**
 * Enable the specified {@link GatewayIntent GatewayIntents}.
 * <br>This will not disable any currently set intents.
 *
 * @param  intents
 *         The intents to enable
 *
 * @throws IllegalArgumentException
 *         If provided with null
 *
 * @return The DefaultShardManagerBuilder instance. Useful for chaining.
 *
 * @see    #disableIntents(Collection)
 */
@Nonnull
public DefaultShardManagerBuilder enableIntents(@Nonnull Collection<GatewayIntent> intents)
{
    Checks.noneNull(intents, "GatewayIntent");
    int raw = GatewayIntent.getRaw(intents);
    this.intents |= raw;
    return this;
}
 
Example 5
Source File: DefaultShardManagerBuilder.java    From JDA with Apache License 2.0 3 votes vote down vote up
/**
 * Enable the specified {@link GatewayIntent GatewayIntents}.
 * <br>This will not disable any currently set intents.
 *
 * @param  intent
 *         The intent to enable
 * @param  intents
 *         Other intents to enable
 *
 * @throws IllegalArgumentException
 *         If provided with null
 *
 * @return The DefaultShardManagerBuilder instance. Useful for chaining.
 *
 * @see    #enableIntents(GatewayIntent, GatewayIntent...)
 */
@Nonnull
public DefaultShardManagerBuilder enableIntents(@Nonnull GatewayIntent intent, @Nonnull GatewayIntent... intents)
{
    Checks.notNull(intent, "GatewayIntent");
    Checks.noneNull(intents, "GatewayIntent");
    int raw = GatewayIntent.getRaw(intent, intents);
    this.intents |= raw;
    return this;
}
 
Example 6
Source File: JDABuilder.java    From JDA with Apache License 2.0 3 votes vote down vote up
/**
 * Configures which events will be disabled.
 * Bots which did not enable presence/member updates in the developer dashboard are required to disable {@link GatewayIntent#GUILD_PRESENCES} and {@link GatewayIntent#GUILD_MEMBERS}!
 *
 * <p>It is not recommended to disable {@link GatewayIntent#GUILD_MEMBERS GatewayIntent.GUILD_MEMBERS} when
 * using {@link MemberCachePolicy#ALL MemberCachePolicy.ALL} as the members cannot be removed from cache by a leave event without this intent.
 *
 * <p>If you disable certain intents you also have to disable related {@link CacheFlag CacheFlags}.
 * This can be achieved using {@link #disableCache(CacheFlag, CacheFlag...)}. The required intents for each
 * flag are documented in the {@link CacheFlag} enum.
 *
 * @param  intents
 *         The intents to disable (default: none)
 *
 * @return The JDABuilder instance. Useful for chaining.
 *
 * @see    #setMemberCachePolicy(MemberCachePolicy)
 *
 * @since  4.2.0
 */
@Nonnull
public JDABuilder setDisabledIntents(@Nullable Collection<GatewayIntent> intents)
{
    this.intents = GatewayIntent.ALL_INTENTS;
    if (intents != null)
        this.intents &= ~GatewayIntent.getRaw(intents);
    return this;
}
 
Example 7
Source File: JDABuilder.java    From JDA with Apache License 2.0 3 votes vote down vote up
/**
 * Disable the specified {@link GatewayIntent GatewayIntents}.
 * <br>This will not enable any currently unset intents.
 *
 * <p>If you disable certain intents you also have to disable related {@link CacheFlag CacheFlags}.
 * This can be achieved using {@link #disableCache(CacheFlag, CacheFlag...)}. The required intents for each
 * flag are documented in the {@link CacheFlag} enum.
 *
 * @param  intents
 *         The intents to disable
 *
 * @throws IllegalArgumentException
 *         If provided with null
 *
 * @return The JDABuilder instance. Useful for chaining.
 *
 * @see    #enableIntents(Collection)
 */
@Nonnull
public JDABuilder disableIntents(@Nonnull Collection<GatewayIntent> intents)
{
    Checks.noneNull(intents, "GatewayIntent");
    int raw = GatewayIntent.getRaw(intents);
    this.intents &= ~raw;
    return this;
}
 
Example 8
Source File: JDABuilder.java    From JDA with Apache License 2.0 3 votes vote down vote up
/**
 * Disable the specified {@link GatewayIntent GatewayIntents}.
 * <br>This will not enable any currently unset intents.
 *
 * <p>If you disable certain intents you also have to disable related {@link CacheFlag CacheFlags}.
 * This can be achieved using {@link #disableCache(CacheFlag, CacheFlag...)}. The required intents for each
 * flag are documented in the {@link CacheFlag} enum.
 *
 * @param  intent
 *         The intent to disable
 * @param  intents
 *         Other intents to disable
 *
 * @throws IllegalArgumentException
 *         If provided with null
 *
 * @return The JDABuilder instance. Useful for chaining.
 *
 * @see    #enableIntents(GatewayIntent, GatewayIntent...)
 */
@Nonnull
public JDABuilder disableIntents(@Nonnull GatewayIntent intent, @Nonnull GatewayIntent... intents)
{
    Checks.notNull(intent, "GatewayIntent");
    Checks.noneNull(intents, "GatewayIntent");
    int raw = GatewayIntent.getRaw(intent, intents);
    this.intents &= ~raw;
    return this;
}
 
Example 9
Source File: JDABuilder.java    From JDA with Apache License 2.0 3 votes vote down vote up
/**
 * Enable the specified {@link GatewayIntent GatewayIntents}.
 * <br>This will not disable any currently set intents.
 *
 * @param  intents
 *         The intents to enable
 *
 * @throws IllegalArgumentException
 *         If provided with null
 *
 * @return The JDABuilder instance. Useful for chaining.
 *
 * @see    #disableIntents(Collection)
 */
@Nonnull
public JDABuilder enableIntents(@Nonnull Collection<GatewayIntent> intents)
{
    Checks.noneNull(intents, "GatewayIntent");
    int raw = GatewayIntent.getRaw(intents);
    this.intents |= raw;
    return this;
}
 
Example 10
Source File: JDABuilder.java    From JDA with Apache License 2.0 3 votes vote down vote up
/**
 * Enable the specified {@link GatewayIntent GatewayIntents}.
 * <br>This will not disable any currently set intents.
 *
 * @param  intent
 *         The intent to enable
 * @param  intents
 *         Other intents to enable
 *
 * @throws IllegalArgumentException
 *         If provided with null
 *
 * @return The JDABuilder instance. Useful for chaining.
 *
 * @see    #enableIntents(GatewayIntent, GatewayIntent...)
 */
@Nonnull
public JDABuilder enableIntents(@Nonnull GatewayIntent intent, @Nonnull GatewayIntent... intents)
{
    Checks.notNull(intent, "GatewayIntent");
    Checks.noneNull(intents, "GatewayIntent");
    int raw = GatewayIntent.getRaw(intent, intents);
    this.intents |= raw;
    return this;
}