Java wrapper for the popular chat & VOIP service: Discord https://discord.com
APACHE-2.0 License
Bot releases are hidden (Show)
Published by MinnDevelopment 5 months ago
This is a small bugfix release, including some missing features for premium app entitlements.
This release adds support for test entitlements and consumed entitlements.
An entitlement can be consumed, marking it as already used. This can be useful for one-time entitlements, which are consumed on use.
public boolean hasEntitlement(long skuId, List<Entitlement> entitlements) {
return entitlements.stream().anyMatch(e -> e.getSkuIdLong() == skuId && !e.isConsumed());
}
public void consumeEntitlement(long skuId, List<Entitlement> entitlements) {
entitlements.stream()
.filter(e -> e.getSkuIdLong() == skuId && !e.isConsumed())
.findFirst()
.ifPresent(entitlement -> entitlement.consume().queue());
}
IPostContainerManager#setTopic
by @freya022 in https://github.com/discord-jda/JDA/pull/2666
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.23...v5.0.0-beta.24
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.24")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.24</version>
</dependency>
Published by MinnDevelopment 6 months ago
This release includes an updated README, please let us know if you spot any issues with it!
Discord has recently released a new feature on their platform to start and vote in polls. These polls can now be sent in messages:
channel.sendMessage("Hello guys! Check my poll:")
.setPoll(
MessagePollData.builder("Which programming language is better?")
.addAnswer("Java", Emoji.fromFormatted("<:java:1006323566314274856>"))
.addAnswer("Kotlin", Emoji.fromFormatted("<:kotlin:295940257797636096>"))
.build())
.queue()
The poll automatically expires after a set duration, configurable in the MessagePollBuilder
using setDuration. A poll can also be ended manually using endPoll or endPollById.
You can check the poll votes on a message using the new Message#getPoll
:
MessagePoll poll = message.getPoll();
for (MessagePoll.Answer answer : poll.getAnswers()) {
System.out.printf("Poll Answer %s has %d votes\n", answer.getText(), answer.getVotes());
}
[!NOTE]
The votes for polls are eventually consistent and need to be recounted after the poll ends. You can check whether the votes are validated using MessagePoll#isFinalizedVotes.
CommandInteractionPayload#getCommandString
in autocomplete interactions by @freya022 in https://github.com/discord-jda/JDA/pull/2659
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.22...v5.0.0-beta.23
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.23")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.23</version>
</dependency>
Published by MinnDevelopment 6 months ago
This release adds some newer API features, like premium app subscriptions, bot banners, and bulk banning users.
Besides new features, this release also includes improved errors and bug fixes.
If your bot is eligible for monetization, you can now use JDA to handle entitlements in interactions to restrict features. With event.replyWithPremiumRequired()
, you can upsell a premium subscription to a user:
Read more about entitlements and premium app subscriptions in the Discord Developer Docs.
You can now ban up to 200 users in one request using guild.ban(users, messageDeleteTimeframe)
.
This endpoint has a few quirks to keep in mind:
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.21...v5.0.0-beta.22
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.22")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.22</version>
</dependency>
Published by MinnDevelopment 7 months ago
This release fixes a few bugs but also implements a new behavior on message sending.
With the new enforce nonce behavior, messages will no longer be duplicated due to timeouts or discord outages. This means, any message request will now send an automatically generated nonce. You can still set a custom nonce using setNonce, but you should make sure that this nonce is unique. If you previously relied on this setter, ensure that you are not sending duplicated nonce values.
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.20...v5.0.0-beta.21
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.21")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.21</version>
</dependency>
Published by MinnDevelopment 9 months ago
With this release, we reworked a lot of internals related to how we cache channels. Ideally, you should not notice any difference.
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.19...v5.0.0-beta.20
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.20")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.20</version>
</dependency>
Published by MinnDevelopment 10 months ago
Smaller release with some bug fixes and added support for voice channel status feature.
Bots can now configure the voice channel status, shown when opening a voice channel in full screen mode. This works similarly to a channel topic, but can be configured by everyone who is currently connected to the channel.
The new VOICE_SET_STATUS
permission indicates whether a user can change the channel status while they are connected. When a user is not connected to the channel, the MANAGE_CHANNEL
permission is required instead (similar to topics).
Note that this feature might be replaced by a new "hang status" in the future, which would instead show on the user rather than the channel.
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.18...v5.0.0-beta.19
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.19")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.19</version>
</dependency>
Published by MinnDevelopment 11 months ago
This release fixes a race-condition in the default rate-limiter implementation that very rarely resulted in an orphaned rate-limit bucket.
Sometimes the cleanup of buckets resulted in an active rate-limit bucket being orphaned. This means that the bucket was continuously trying to execute the same request without updating its state.
This release should resolve that problem, fixing the occasional bug where a 429 response was handled incorrectly.
The default thread model used for the handling of rate-limits has been changed. Instead of using a single scheduled executor, we now make use of an additional elastic pool that automatically scales up and down based on how many buckets run concurrently.
In the previous model, the scheduled executor limited the capabilities by only providing a fixed amount of threads. To handle scaling with larger bots, we simply used 5 threads for each shard. This has been adjusted now to use a shared pool, which scales up and down based on load instead.
Please let us know if you run into any problems with the defaults in your deployments!
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.17...v5.0.0-beta.18
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.18")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.18</version>
</dependency>
Published by MinnDevelopment 12 months ago
This release fixes some issues with webhook executions in thread channels.
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.16...v5.0.0-beta.17
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.17")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.17</version>
</dependency>
Published by MinnDevelopment 12 months ago
With this release, we have redesigned a major flaw in our entity constraints. Previously, message instances required a known cached channel instance to be usable. This flaw has been remedied by reworking this implementation to be usable with only a known channel id.
This means, that methods such as message.addReaction(...)
or message.pin()
can now work for message instances that have no channel object in cache. You can find out if a channel is available on a message instance, by using hasChannel. Adding support for this behavior was necessary, in order to implement webhook executions!
With this change resolved, we can now fully support sending messages through arbitrary webhooks by using WebhookClient.createClient
. This webhook client makes use of the JDA rate-limit system and request queue, to properly handle rate-limits for you.
This release also fixes the problem of not receiving interactions in hidden threads, for instance if the thread is a private thread and your bot has not been added yet. This problem was actually caused by JDA expecting a channel instance in cache that was not present, which stopped the interaction from going through.
Discord has added more information about the channel objects in interactions, so we can now properly construct the thread channel instance just in time for the interaction event.
Your bot can now tell what super-reactions are used. You still cannot send them because the API is too unstable.
We plan to end the beta period for JDA 5.0.0 very soon. There are a few more changes we are thinking of merging first, but the current release already seems very complete. We hope to end the beta period before the end of the year, stay tuned.
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.15...v5.0.0-beta.16
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.16")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.16</version>
</dependency>
Published by MinnDevelopment about 1 year ago
This release fixes a bug introduced by 5.0.0-beta.14
.
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.14...v5.0.0-beta.15
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.15")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.15</version>
</dependency>
Published by MinnDevelopment about 1 year ago
This brings JDA up to date with newly released API features and fixes a few issues.
Many years ago, the "Custom Status" feature has been released on Discord, but has since been limited to client users. With a change recently, bots have finally been granted access to set this custom status as well. This, however, is limited to only setting the text value and no emoji.
You can set a custom status using Activity.customStatus(text)
.
Discord is rolling out another new channel type. This time the type is a derivation of forum channels, specifically designed to share media such as images or videos. This release adds support for media channels.
A few places now return the new abstraction IPostContainer
, where previously a ForumChannel
was used. This abstraction is used to deduplicate and expand the API to handle both media and forum channels equally, as both of these types handle posts (threads with start messages).
The member cache has become slightly more powerful by introducing the new LRUMemberCachePolicy
. A Least-Recently-Used (LRU) cache keeps members cached based on activity.
Example:
MemberCachePolicy.VOICE // Keep in cache if currently in voice (skip LRU and ONLINE)
.or(MemberCachePolicy.ONLINE) // Otherwise, only add to cache if online
.and(MemberCachePolicy.lru(1000) // keep 1000 recently active members
.unloadUnless(MemberCachePolicy.VOICE)) // only unload if they are not in voice
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.13...v5.0.0-beta.14
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.14")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.14</version>
</dependency>
Published by MinnDevelopment about 1 year ago
This release includes a few bug fixes and a new FileUpload
variant to optimize memory usage when uploading larger files.
With the new FileUpload.fromStreamSupplier
, an upload will no longer retain the entire file content in memory. This comes at the cost of having to re-read the source each time.
Example:
FileUpload.fromStreamSupplier("image.png", () -> {
return new FileInputStream("myimage.png");
});
Each time the request is attempted, which can be more than once due to rate-limit retries, the supplier is used to create a new readable input stream of the file. Once the request successfully writes the entire body, the stream is closed again.
Note that the supplier must always return a new instance or reset the stream accordingly.
The MessageReactionAddEvent
now provides the author id of the original message. This can be useful in situations where retrieving the message is too expensive.
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.12...v5.0.0-beta.13
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.13")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.13</version>
</dependency>
Published by MinnDevelopment over 1 year ago
This release fixes a few annoying bugs that were introduced by the username changes.
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.11...v5.0.0-beta.12
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.12")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.12</version>
</dependency>
Published by MinnDevelopment over 1 year ago
This release fixes a few issues introduced by the username changes. It also introduces EmbedBuilder.fromData
as a way to deserialize embeds from JSON.
There are also some changes to our online presence.
Using the new EmbedBuilder.fromData
factory method, you can now create embed instances from JSON or ETF data.
MessageEmbed embed = new EmbedBuilder().setDescription("Hello, friend").build();
byte[] data = embed.toData().toJson(); // serialize to json data
Files.write(path, json); // store the embed somewhere on disk
DataObject json = DataObject.fromJson(Files.newInputStream(path)); // load the json data
MessageEmbed reconstructed = EmbedBuilder.fromData(json).build(); // reconstruct the same embed using the builder
Full Changelog: https://github.com/discord-jda/JDA/compare/v5.0.0-beta.10...v5.0.0-beta.11
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.11")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.11</version>
</dependency>
Published by MinnDevelopment over 1 year ago
With this release, we are taking the first steps to transition into the new username system for Discord by marking some methods as incubating or deprecated. This release also introduces support for AutoMod, both events and changing the AutoMod rules of a guild.
You can now modify the AutoMod rules of a guild using AutoModRuleData
and Guild#createAutoModRule
.
Support for member profile AutoMod has not been added yet, due to the API being very unstable still.
Example
guild.createAutoModRule(
AutoModRule.onMessage("No morbius memes", TriggerConfig.keywordFilter("*morb*"))
.putResponses(AutoModResponse.blockMessage("This meme is unfunny."))
).queue();
Discord is changing to globally unique usernames and removing discriminators, this is explained in their blog post. We are taking the first steps to transition with this release.
Deprecated Features
Incubating Features
These are likely to be deprecated and removed in the future.
Other Changes
User#getDiscriminator
will return "0000"
for users who have a globally unique username from the new system.User#getEffectiveName
has been introduced to get the "effective display name" of a user, meaning either the User#getGlobalName
or User#getName
. This also affects Member#getEffectiveName
, which will now return based on precedence guild nickname
> global name
> username
.User#getDefaultAvatarId
now depends on the user id instead of the discriminator (when they have the discriminator 0000)Full Changelog: https://github.com/DV8FromTheWorld/JDA/compare/v5.0.0-beta.9...v5.0.0-beta.10
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.10")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.10</version>
</dependency>
Published by MinnDevelopment over 1 year ago
This release fixes a few critical bugs related to rate-limiting. We also added support for voice message receiving and new permissions relating to soundboards.
You can now use EmbedBuilder#setUrl
to create multi-image embeds. To create multi-image embeds, simply create one embed for each image and set the same URL on all of them. The client automatically merges embeds with the same URL.
Full Changelog: https://github.com/DV8FromTheWorld/JDA/compare/v5.0.0-beta.8...v5.0.0-beta.9
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.9")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.9</version>
</dependency>
Published by MinnDevelopment over 1 year ago
This is a small hotfix release for an error introduced in beta 7.
Full Changelog: https://github.com/DV8FromTheWorld/JDA/compare/v5.0.0-beta.7...v5.0.0-beta.8
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.8")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.8</version>
</dependency>
Published by MinnDevelopment over 1 year ago
You can now use RestConfig
to customize parts of the REST handling in JDA. This allows you to create custom rate-limiter implementations and make use of rate-limit proxy services such as http-proxy.
Using RestConfig, you can change parts of the REST handling. This allows you to append to the User-Agent, add custom headers, or even completely replace the existing Rate-Limiter handling:
RestConfig config = new RestConfig();
config.setUserAgentSuffix("custom suffix"); // Changes user-agent to "DiscordBot(JDA, ...) custom suffix"
config.setBaseUrl("https://proxy.example.com/api/v10"); // requests will now go through this endpoint, allowing custom rate-limits
config.setRateLimiterFactory(...); // change the handling of rate-limits
builder.setRestConfig(config); // then simply set it on your JDABuilder or DefaultShardManagerBuilder
This can also be useful to implement a different queue system for rate-limit handling. By default, JDA will always use the SequentialRateLimiter, which handles requests to the same rate-limit bucket in sequence to avoid messages being unordered. A custom implementation could replace this to run requests in parallel.
To implement a custom rate-limiter, use the existing RestRateLimiter interface and implement the required methods as documented. Your implementation will be provided with Work instances to handle.
You can now access the flags on members and modify them. This allows to check if a member has rejoined the guild or passed onboarding. The rejoin flag is not entirely reliable, since Discord has only started tracking rejoins recently. Members who rejoined years ago will not have this flag set.
With Member#modifyFlags
, you can change some of these flags. Only a subset of the existing flags are modifiable.
EnumSet<MemberFlag> flags = member.getFlags();
flags.add(MemberFlag.BYPASS_VERIFICATION); // Member bypasses verification level on guild
member.modifyFlags(flags).queue();
Full Changelog: https://github.com/DV8FromTheWorld/JDA/compare/v5.0.0-beta.6...v5.0.0-beta.7
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.7")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.7</version>
</dependency>
Published by MinnDevelopment over 1 year ago
This release adds support for messages and interactions inside stage channels.
Full Changelog: https://github.com/DV8FromTheWorld/JDA/compare/v5.0.0-beta.5...v5.0.0-beta.6
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.6")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.6</version>
</dependency>
Published by MinnDevelopment over 1 year ago
This is a minor release with some important bug fixes. All bots relying on voice connections should apply this update as soon as possible.
Full Changelog: https://github.com/DV8FromTheWorld/JDA/compare/v5.0.0-beta.4...v5.0.0-beta.5
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.5")
}
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.5</version>
</dependency>