Skip to content

v5.0.0 | End of beta phase

Latest
Compare
Choose a tag to compare
@MinnDevelopment MinnDevelopment released this 07 Jul 18:43
· 1 commit to master since this release
2269f42

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 becomes SlashCommandInteractionEvent
  • ButtonClickEvent becomes ButtonInteractionEvent

Similarly, we've renamed component types slightly:

  • SelectionMenu is now StringSelectMenu, while adding a new EntitySelectMenu
  • What was previously called Component has now been renamed to ActionComponent and ItemComponent, allowing us to introduce Component as an abstraction over both Button and ActionRow (which is now a LayoutComponent). The new Component interface is now an abstraction over both ItemComponent and LayoutComponent.

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:

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 types
  • StickerItem, stickers found in messages
  • RichSticker, stickers with more information that is usually omitted for messages (sticker items)
  • StandardSticker, rich stickers provided by nitro instead of guilds
  • GuildSticker, rich stickers provided in guilds
  • StickerUnion, 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.

Changelog (4.4.0 -> 5.0.0)

Note that this changelog is a linear history of changes. This means some earlier changes have already been superseded or refined in more recent changes. This changelog is slightly compressed to remove unimportant changes, you can see the full list of commits here.

Thank you all for contributing!

New Features

New feature additions since 4.4.0

Breaking Changes

Breaking changes since 4.4.0

Other Changes

Other noteworthy changes since 4.4.0

Bug Fixes

Bugs fixed since 4.4.0