v4.1.0 | Be More Lazy
We added support for lazy loading and now allow to disable guild subscriptions!
To enable lazy loading you have to configure a ChunkingFilter
on your builder of choice [1]. Lazy loading means that JDA will not attempt to request the entire member list of a guild before starting to send events. Instead, members will be loaded on their first activity and members who are never active will never be loaded into cache.
new JDABuilder(TOKEN)
.setChunkingFilter(ChunkingFilter.NONE) // don't chunk any guilds
.build();
1) Example how to enable lazy loading
The more extreme choice is to disable guild subscriptions [2]. This feature completely disables member and user cache for the shard/jda session. Note that if you need methods like Guild#getMembers
or similar things that require knowledge of the entire member list this is not something you should be using. JDA cannot determine the size of a guild or member join/leave with this disabled. The benefit of this is a greatly reduced memory footprint with the disadvantage of losing member state tracking.
new JDABuilder(TOKEN)
.setGuildSubscriptionsEnabled(false)
.build();
2) Example how to disable guild subscriptions
A footnote is that CacheFlag.VOICE_STATE
can still be tracked and users in voice channels will still be loaded into cache when this cache flag is enabled. This is useful for music bots that want to leave a voice channel if they are alone.
You can now ignore specific ErrorResponse
failures more easily. With ErroResponseException.ignore(...)
you can create a failure consumer that drops any ErrorResponseException
for the specified set of responses. [3]
import static net.dv8tion.jda.api.exceptions.ErrorResponseException.ignore;
import static net.dv8tion.jda.api.requests.ErrorResponse.*;
message.delete().queue(null, ignore(UNKNOWN_MESSAGE)); // ignore if message doesn't exist anymore
message.delete().queue(null, ignore(Logger::error, UNKNOWN_MESSAGE)); // ignore otherwise log
3) Example how to ignore UNKNOWN_MESSAGE errors
New Features
- Lazy Loading and disable guild subscriptions
- Readonly support for custom status
Member#getActiveClients
ErrorResponseException.ignore(...)
Deprecation
Detailed javadoc can be found in the deprecated tab of the docs
GuildUnavailableException
,Guild#isAvailable
this is no longer used, unavailable guilds are no longer in the guild cache. You can check if a guild is unavailable withJDA#getUnavailableGuilds
Guild#retrieveVanityUrl
replace withGuild#getVanityUrl
Invite#getCreationTime
replace withInvite#getTimeCreated
JDA#getVoiceChannelByName
replace withJDA#getVoiceChannelsByName
ShardManager#setGame
replace withShardManager#setActivity
SessionController#getGatewayBot
replace withSessionController#getShardedGateway
Incubating
AccountType#CLIENT
this is most likely going to break soon with impending changes to the gatewayJDABuilder(AccountType)
this will be removed whenAccountType#CLIENT
breaks in the futureActivity#watching
,ActivityType#WATCHING
this is not officially supported by the API but currently usableActivityType#CUSTOM_STATUS
this is currently not usable for bots and can only be seen on other usersAudioManager#getSpeakingMode
,AudioManager#setSpeakingMode
this is not a confident implementation and should be used with care
Installation
The release version is: 4.1.0_81
The latest version is:
Gradle
repositories {
jcenter()
}
dependencies {
compile "net.dv8tion:JDA:4.1.0_81"
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.1.0_81</version>
</dependency>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
Pull Requests
You can view the 4.1.0 Milestone for a list of accepted pull requests for this release. Thank you to everyone who contributed!