Releases: discord-jda/JDA
v5.0.2 | Single time event listener
Overview
This release includes some bug fixes as well as a new event listener feature to add a one-time-use event listener.
Once Event Listener (#2683)
A common problem that developers run into, is "waiting" for a specific event in the context of some command. For instance, waiting for a user to add a reaction or reply with a message in response to some prompt.
This can now be achieved using the new listenOnce event listener:
// listen for a message event
jda.listenOnce(MessageReceivedEvent.class)
// filter for specific event
.filter(event -> event.getChannel().equals(channel))
.filter(event -> event.getAuthor().equals(user))
// handle timeout
.timeout(timeout, () -> hook.editOriginal("Timeout!").queue())
// subscribe to first event that matches filters
.subscribe(event -> {
hook.editOriginal("You sent: " + event.getMessage().getContentRaw()).queue();
});
New Features
- Add
TeamMember.RoleType
by @freya022 in #2703 - Add abstract
createCopy
method inSelectMenu
by @Kaktushose in #2684 - Add
JDA#listenOnce
by @freya022 in #2683 - Add support for profile automod by @MinnDevelopment in #2580
Changes
- Expand list of retried http error codes by @MinnDevelopment in #2710
- Update to Jackson 2.17.2 by @freya022 in #2695
Bug Fixes
Full Changelog: v5.0.1...v5.0.2
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.2")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.2</version>
</dependency>
v5.0.1 | Hotfix shard manager thread handling
Overview
Small hotfix release, fixes problem with default thread config for DefaultShardManager
. This caused requests to fail if a shard is stopped or restarted.
Bug Fixes
- Fix automatic shutdown for elastic pool by @MinnDevelopment in #2704
Full Changelog: v5.0.0...v5.0.1
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.1")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.1</version>
</dependency>
v5.0.0 | End of beta phase
The Long Awaited Stabilization
After almost 3 years of refactoring and polishing, the stabilization of JDA 5.0.0 is here. If you have been following along, not much has changed since the latest beta release.
If you have somehow avoided updating to a beta release since 2021, here is a list of the most noteworthy additions, changes, and bug fixes since 4.4.0.
You can also use our Migration Guide to help you update to the latest version of JDA 5. This guide also includes the most important changes you need to consider.
Interactions / Application Features
Discord has further improved the capabilities of applications with new types of interactions. This major release of JDA adds support for these features, coming with some restructuring to properly accomodate the new types.
We've renamed interaction events to a more consistent naming scheme:
SlashCommandEvent
becomesSlashCommandInteractionEvent
ButtonClickEvent
becomesButtonInteractionEvent
Similarly, we've renamed component types slightly:
SelectionMenu
is nowStringSelectMenu
, while adding a newEntitySelectMenu
- What was previously called
Component
has now been renamed toActionComponent
andItemComponent
, allowing us to introduceComponent
as an abstraction over bothButton
andActionRow
(which is now aLayoutComponent
). The newComponent
interface is now an abstraction over bothItemComponent
andLayoutComponent
.
To learn more about interactions in JDA 5, take a look at our Interactions Wiki Guide.
Channel Type Rework
We've refactored the channel types and usages in JDA to be more maintainable. Each type of channel now directly maps to a specific channel interface, unlike before where VoiceChannel
was used for both stage and voice type channels.
Instead there are now concrete interfaces for each type, such as NewsChannel
, StageChannel
, ForumChannel
, etc.
The channel type hierarchy has been further refined, by introducing higher level abstractions to represent the features of multiple channel types:
As well as more specific features or attributes of channels:
To properly maintain these many different channel types and make them easy to use, we've also introduced new union types to encompass multiple channels into a simple common union type. This replaces the old getTextChannel()
/getVoiceChannel()
getters on events with getChannel().asTextChannel()
. However, you can also use the standard features of the unions directly. For instance, a MessageChannelUnion
allows to send messages and these specialization methods:
MessageChannelUnion channel = event.getChannel();
channel.sendMessage("hello").queue();
if (channel.getType() == TEXT) {
channel.asTextChannel().getManager().setTopic("test topic").queue();
}
Cache access has also seen some improvement, by introducing a new getChannelById(Class, long)
method, allowing to just get a MessageChannel
without worrying about the concrete type.
GuildMessageChannel channel = guild.getChannelById(GuildMessageChannel.class, 125227483518861312L);
channel.sendMessage("Hello general chat!").queue();
Learn more about the channel rework in Channel Rework.
Message Features
We've refactored our message sending interfaces to be more consistent, by abstracting MessageAction
, MessageBuilder
, and ReplyAction
into shared interfaces MessageCreateRequest
and MessageEditRequest
. This makes all message sending code consistent. We recommend to simply chain your builder-like code directly on send messages:
channel.sendMessage("Hello World")
.setComponents(ActionRow.of(button1, button2))
.setEmbeds(embed1, embed2)
.setFiles(files)
.queue();
However, if you need to use builders, we've introduced MessageEditBuilder and MessageCreateBuilder to replace the old MessageBuilder
utility. You can also now use SplitUtil
to easily divide message content into multiple messages.
To support file descriptions and reduce the number of sendFile overloads, we've also introduced a new FileUpload
type that unifies all attachments into a single type.
FileUpload file = FileUpload.fromData(new File("myFile.png"), "image.png")
.setDescription("this is my alt text for screenreaders, allowing to make accessible images in your messages!");
channel.sendFiles(file).queue();
Learn more about the changes to message sending in Message Send/Edit Rework.
Emojis and Stickers
In JDA 5, we have decided to unify all emoji types into a consistent type structure:
Emoji
, a top-level interface representing all emoji as well as a type discriminator withEmoji#getType
UnicodeEmoji
, standard unicode emoji such as 🤔CustomEmoji
, custom emoji found in messages, like<:minn:245267426227388416>
RichCustomEmoji
, emoji with more information such as owner, accessible through the guild settings.EmojiUnion
, adding type casting for things likeMessageReaction#getEmoji
These new emoji types replace the duplication of ReactionEmote
and Activity.Emoji
.
Stickers have also been refactored in a similar way, making a clear distinction between stickers found in messages and guild settings:
Sticker
, a top-level abstraction of all sticker typesStickerItem
, stickers found in messagesRichSticker
, stickers with more information that is usually omitted for messages (sticker items)StandardSticker
, rich stickers provided by nitro instead of guildsGuildSticker
, rich stickers provided in guildsStickerUnion
, adding type casting
Learn more about the changes to emojis and stickers in Sticker and Emoji Rework.
Installation
All future JDA releases will be distributed through maven central. You no longer need to use jcenter()
in your dependency manager.
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0</version>
</dependency>
Changelog (5.0.0-beta.24 -> 5.0.0)
The changes since the latest beta release to this release.
- Allow UserSnowflake subtypes in bulk ban methods by @freya022 (#2689)
- Update MessageType enum by @MinnDevelopment (#2691)
- Improve Unknown Interactio...
v5.0.0-beta.24 | Bug fixes and entitlement types
Overview
This is a small bugfix release, including some missing features for premium app entitlements.
Additional Entitlement Features (#2667)
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());
}
New Features
- Add
IPostContainerManager#setTopic
by @freya022 in #2666 - Add missing features relating to premium app subscriptions by @Tobias123567 in #2667
Changes
- Improve logging for gateway connection by @MinnDevelopment in #2665
- Add more static analyzer annotations by @MinnDevelopment in #2675
- Update SLF4J api and jackson by @MinnDevelopment in #2674
Bug Fixes
- Fix ClassCastException in EntityBuilder#updateMemberCache by @Xirado in #2660
- Properly copy poll data in MessageCreateRequest#applyData by @MinnDevelopment in #2662
- Make channel access checks consistent by @MinnDevelopment in #2679
Full Changelog: v5.0.0-beta.23...v5.0.0-beta.24
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.24")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.24</version>
</dependency>
v5.0.0-beta.23 | Message Polls
Overview
This release includes an updated README, please let us know if you spot any issues with it!
Polls (#2649)
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.
New Features
- Add USER_MUST_BE_VERIFIED ErrorResponse by @GitMilchi in #2651
- Update permission enum by @MinnDevelopment in #2654
- Poll support by @MinnDevelopment in #2649
Changes
- Update dependencies and use version catalog by @MinnDevelopment in #2652
Bugs Fixes
Full Changelog: v5.0.0-beta.22...v5.0.0-beta.23
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.23")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.23</version>
</dependency>
v5.0.0-beta.22 | Bulk ban, premium apps, bug fixes
Overview
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.
Premium App Subscriptions (#2583)
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.
Bulk Ban (#2630)
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:
- The BulkBanResponse includes failed users and banned users
- If a user was already banned, they are in the failed users
- If you don't have permissions to ban a user (higher role / owner), they also appear in failed users
- The self user also appears in failed users
- If all users "failed" you get an error response instead
New Features
- Add support for bulk banning users by @MinnDevelopment in #2630
- Add the ability to set the bot banner by @freya022 in #2629
- Add support for premium app subscriptions by @Giuliopime in #2583
Changes
Bug Fixes
- Fix format specifiers when adding invalid choices by @freya022 in #2628
- Fix FlatMapRestAction predicate with complete or submit by @Whizyyy in #2636
- Handle numeric keys for ETF maps by @MinnDevelopment in #2642
Full Changelog: v5.0.0-beta.21...v5.0.0-beta.22
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.22")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.22</version>
</dependency>
v5.0.0-beta.21 | Bug fixes and enforced nonce on messages
Overview
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.
New Features
- Add DiscordLocale values for these locales: Indonesian and Latin America (Spanish LATAM) by @stackpan in #2627
Changes
- Add support for enforce_nonce by @MinnDevelopment in #2614
Bug Fixes
- Add missing generic type to shardmanager by @duncte123 in #2612
- Add missing proxy url field to the MessageEmbed.VideoInfo class by @shaksternano in #2618
- Fix suppressing embeds on messages with webhooks by @freya022 in #2620
Full Changelog: v5.0.0-beta.20...v5.0.0-beta.21
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.21")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.21</version>
</dependency>
v5.0.0-beta.20 | Bug fixes and internal refactoring
Overview
With this release, we reworked a lot of internals related to how we cache channels. Ideally, you should not notice any difference.
New Features
Changes
- Unified channel cache by @MinnDevelopment in #2528
- Return immutable lists when documented by @freya022 in #2607
Bug Fixes
- Fix clearing of voice status by @MinnDevelopment in #2601
- Handle canTalk for private threads in interactions by @MinnDevelopment in #2603
Full Changelog: v5.0.0-beta.19...v5.0.0-beta.20
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.20")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.20</version>
</dependency>
v5.0.0-beta.19 | Bug fixes and voice channel status
Overview
Smaller release with some bug fixes and added support for voice channel status feature.
Voice Channel Status (#2532)
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.
New Features
- Add voice status feature by @MinnDevelopment in #2532
Changes
- Add more logging to request handling by @MinnDevelopment in #2589
- Add missing message types by @MinnDevelopment in #2531
- Updating Dependencies by @Lewox in #2591
- Add check for max number of fields in EmbedBuilder by @Andre601 in #2592
Bug Fixes
- Fix incorrect hook injection for message context commands by @MinnDevelopment in #2593
Full Changelog: v5.0.0-beta.18...v5.0.0-beta.19
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.19")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.19</version>
</dependency>
v5.0.0-beta.18
Overview
This release fixes a race-condition in the default rate-limiter implementation that very rarely resulted in an orphaned rate-limit bucket.
Orphan Rate-Limit Buckets (#2585)
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.
New Thread Model (#2463)
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!
New Features
Changes
- Change thread model used for requests by @MinnDevelopment in #2463
- Remove outdated todo comments and update outdated logic in thread channels by @MinnDevelopment in #2581
Bug Fixes
- Fix orphaned rate-limit buckets by @MinnDevelopment in #2585
- Fix incorrect index used in attachment update requests by @MinnDevelopment in #2588
Full Changelog: v5.0.0-beta.17...v5.0.0-beta.18
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.18")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.18</version>
</dependency>