Releases: discord-jda/JDA
v5.0.0-alpha.14 | Text in Voice and Upgrade to API v10
Overview
Breaking changes and text messages in voice channels!
Text in Voice (#2072)
This release introduces the long awaited Text in Voice feature. Now you can use all your message related features in voice channels as well! Automatically works with interactions, messages, reactions, and all other features you could want!
Command Localization (#2090)
Using command localization, you can provide customized translations for all your commands. Check the example: LocalizationExample
API v10 (#2165)
Since the v9 API will be discontinued at the end of 2022, we have upgraded to the newer version 10. This comes with a few breaking changes:
- All edit requests with
addFile
calls (such asmessage.editMessage(...).addFile(...)
), will now remove all current attachments on the message. To retain existing attachments, you are now required to also useretainFiles(...)
with the existing attachments on the message. - The introduction of
GatewayIntent.MESSAGE_CONTENT
. In order to use certain user-generated content in messages, you will now be required to explicitly enable this privileged intent. This includes:getContentRaw
,getContentDisplay
,getContentStripped
, andgetMentions().getCustomEmojis()
getActionRows
, andgetButtons
getAttachments
getEmbeds
You will be presented with a warning, if you try using any of those methods without having the required intent enabled.
Attempting to access message content without GatewayIntent.MESSAGE_CONTENT.
Discord now requires to explicitly enable access to this using the MESSAGE_CONTENT intent.
Useful resources to learn more:
- https://support-dev.discord.com/hc/en-us/articles/4404772028055-Message-Content-Privileged-Intent-FAQ
- https://jda.wiki/using-jda/gateway-intents-and-member-cache-policy/
- https://jda.wiki/using-jda/troubleshooting/#im-getting-closecode4014-disallowed-intents
Or suppress this warning if this is intentional with Message.suppressContentIntentWarning()
Channel Unions (#2138)
We had a lot of repeated concrete type specializations, such as getTextChannel()
, all over library. To address this duplication and to make the interface more consitent, we are introducing the concept of channel unions.
These channel unions, are abstracted types, which provide the same features as their respective name would suggest, while also allowing simple specialization using conversion methods.
An example union would be MessageChannelUnion
, which is used by Message.getChannel()
. This type provides all the methods a normal MessageChannel
would, but also allows you to convert it to a more concrete type:
public void onMessageReceived(MessageReceivedEvent event) {
MessageChannelUnion channel = event.getChannel();
// Use normal message channel features
channel.sendMessage("Hello, I received your message!").queue();
// Specialized handling on concrete types
if (channel.getType() == ChannelType.VOICE) {
VoiceChannel vc = channel.asVoiceChannel(); // easy type conversion, just like casting, but with clear type information
vc.getGuild().getAudioManager().openAudioConnection(vc);
}
}
New Features
- Add JDABuilder#setEventPassthrough by @freya022 in #2014
- Application command localization by @freya022 in #2090
- Handle text in voice channels by @MinnDevelopment in #2072
Changes
- Introduce Channel Unions by @DV8FromTheWorld in #2138
- Add EmojiUnion by @MinnDevelopment in #2167
- Update to API version 10 by @MinnDevelopment in #2165
Bug Fixes
- Fix handling of empty emoji names by @MinnDevelopment in #2176
- Return ThreadChannelAction instead of RestAction on Message#createThreadChannel by @Mitmocc in #2171
- Make MessageType#deletable return an accurate value. by @RedDaedalus in #2160
Full Changelog: v5.0.0-alpha.13...v5.0.0-alpha.14
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.14")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.14</version>
</dependency>
v5.0.0-alpha.13
Overview
In this release, we have taken some time to rework the handling of Emoji and Stickers! This comes with a lot of breaking changes.
Guild Emote Renamed (#2117)
Previously, all custom emoji were called Emote in JDA. This has been changed to be more consistent with the API naming convention of Custom Emoji. In that sense, we renamed Emote to RichCustomEmoji and made various changes all over the API to rename all occurrences of Emote with Emoji.
This also comes with some compatibility improvements! With this change, we now have a uniform representation of all emoji in the library. Every emoji now implements the Emoji interface and can be used interchangeably as such. For instance, the reactions used to have a specific type called ReactionEmote, which is now just replaced with Emoji allowing you to use them in buttons!
public void onMessageReactionAdd(MessageReactionAddEvent event) {
event.getChannel().sendMessage("User reacted")
.setActionRow(Button.primary("buttonid", event.getEmoji())) // <- replacement for getReactionEmote()
.queue();
}
Stickers (#2104)
In addition to the changes for emoji, we now have a full support for stickers! Bots can send up to 3 guild stickers in a message (but not in interactions). However, this is limited to only stickers from the same guild, so likely not useful to most bots.
This comes with support for:
- Creating/Updating/Deleting guild stickers
- Getting and sending stickers with messages
- Access to nitro sticker packs (not sending though)
- Full sticker event support
ChunkingFilter Breaking Change (#2053)
Previously, when you did setChunkingFilter(ChunkingFilter.ALL)
, we would always cache every member of the guild for the full runtime. This has been changed now, allowing you to further configure the member cache policy in addition to chunking. Now, to chunk and cache all members of a guild, you can use setChunkingFilter(ChunkingFilter.ALL).setMemberCachePolicy(MemberCachePolicy.ALL)
.
This is a breaking change and affects anyone using ChunkingFilter.
Command Permissions (#2113)
Discord made breaking changes to command permissions (aka Privileges). This means you can no longer configure the privileges of a command on a guild, without using oauth. Consequently, we updated our interface with breaking changes to address this.
Instead of using setDefaultEnabled(..)
on your command and configuring a whitelist/blacklist of roles and users, you now have the ability to configure allowed permissions using setDefaultPermissions(...)
and you can tell discord that a command is guild only with setGuildOnly(true)
.
However, you cannot configure this for individual subcommands, due to the way discord designed them.
Check out the SlashBotExample for some useful examples on how this works!
New Features
- Rework stickers by @MinnDevelopment in #2104
- Uniform representation of emoji by @MinnDevelopment in #2117
- Add Support for Application-Command Permissions V2 by @Xirado in #2113
Changes
- Changed addField String name and String Value to Nonnull by @RealYusufIsmail in #2133
- Do not ignore member cache policy when chunking is enabled by @MinnDevelopment in #2053
Bug Fixes
- Fix Message.Attachment#getProxy() by @Xirado in #2139
- Fix missing guild id when deleting guild stickers by @CheesyGamer77 in #2144
- Fix filterHidden in GuildImpl#getChannels by @MineKing9534 in #2151
Full Changelog: v5.0.0-alpha.12...v5.0.0-alpha.13
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.13")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.13</version>
</dependency>
v5.0.0-alpha.12
Overview
This release contains a few tiny changes to improve the codebase, such as:
- FileProxy for downloading images and files from discord (replacing Message.Attachments#download)
- FileUpload for uploading images and files to discord (will be used for Message and Sticker creation)
- Message#getMentions to replace all the mention handling in message and interactions. (Such as Message#getMentionedUsers)
Example Mentions Changes
Old:
List<TextChannel> channels = message.getMentionedChannels(); // only handles TextChannel mentions
List<User> users = message.getMentionedUsers();
New:
List<GuildChannel> channels = message.getMentions().getChannels(); // handles all channel mentions
List<MessageChannel> messageChannels = message.getMentions().getChannels(MessageChannel.class); // filter by class type
List<User> users = message.getMentions().getUsers();
New Features
- Add ImageProxy & FileProxy by @freya022 in #1955
- Add new message types for automod by @MinnDevelopment in #2116
- Add Message#getStartedThread and ThreadChannel#retrieveParentMessage by @Almighty-Satan in #2099
- Added getJumpUrl method to GenericMessageEvent by @mufinlive in #2124
- Add FileUpload class by @MinnDevelopment in #2120
Changes
- Remove manager instance cache by @duncte123 in #2106
- Message interface declutter: Message#getMentions() by @DV8FromTheWorld in #2015
Bug Fixes
- Fix broken context map config by @MinnDevelopment in #2110
- Improve check for GuildVoiceState#declineSpeaker by @MinnDevelopment in #2112
- Remove checks for archive durations by @DerBanko in #2127
- [Bugfix] retrieving public archived threads by @Sanduhr32 in #2115
- Fixed deadlock in JDABuilder#login and JDA#shutdown
Full Changelog: v5.0.0-alpha.11...v5.0.0-alpha.12
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.12")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.12</version>
</dependency>
v5.0.0-alpha.11 | Modals
Overview
This release finally brings out modals! This includes a variety of constructs, but the key ones to be immediately aware of are:
- Modal
- TextInput
- ModalInteraction
- ModalInteractionEvent
- IModalCallback (
replyModal(modal)
)
Modal Example
@Override
public void onSlashCommandInteraction(@Nonnull SlashCommandInteractionEvent event) {
if (event.getName().equals("support")) {
TextInput email = TextInput.create("email", "Email", TextInputStyle.SHORT)
.setPlaceholder("Enter your E-mail")
.setMinLength(10)
.setMaxLength(100) // or setRequiredRange(10, 100)
.build();
TextInput body = TextInput.create("body", "Body", TextInputStyle.PARAGRAPH)
.setPlaceholder("Your concerns go here")
.setMinLength(30)
.setMaxLength(1000)
.build();
Modal modal = Modal.create("support", "Support")
.addActionRows(ActionRow.of(email), ActionRow.of(body))
.build();
event.replyModal(modal).queue();
}
}
@Override
public void onModalInteraction(@Nonnull ModalInteractionEvent event) {
if (event.getModalId().equals("support")) {
String email = event.getValue("email").getAsString();
String body = event.getValue("body").getAsString();
createSupportTicket(email, body);
event.reply("Thanks for your request!").setEphemeral(true).queue();
}
}
New Features
Changes
- Fix typos in GatewayIntent Javadoc and contributing guidelines by @CheesyGamer77 in #2098
- prevent creating OptionData with OptionType#UNKNOWN by @caneleex in #2101
Bug Fixes
- Fix NewsChannel#getManager always returning null by @CheesyGamer77 in #2107
Removed
- [Breaking] Remove confusing permission override methods by @MinnDevelopment in #2067
Full Changelog: v5.0.0-alpha.10...v5.0.0-alpha.11
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.11")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.11</version>
</dependency>
v5.0.0-alpha.10
Overview
UserSnowflake
We changed User.fromId
to now return UserSnowflake
instead of User
. This is done to prevent users from attempting code such as User.fromId(123).openPrivateChannel()
which would never work.
With this we also changed some methods to no longer accept raw IDs as long and String. Instead you can now use method(User.fromId(long/String))
, ie. ban(User.fromId(1234))
.
Removed Methods:
- Guild#ban(long/String), Guild#ban(long/String, int), Guild#ban(long/String, int, String)
- Guild#kick(long/String), Guild#kick(long/String, String)
- Guild#unban(long/String)
- Guild#retrieveBanById(long/String)
- Guild#addMember(String, long/String)
- Guild#timeoutForById(long/String, Duration)
- Guild#timeoutUntilById(long/String, TemporalAccessor)
- Guild#removeTimeoutById(long/String)
- Guild#addRoleToMember(long/String, Role)
- Guild#removeRoleFromMember(long/String, Role)
- AuditLogPaginationAction#user(long/String)
New Features
- Add Tags, Default Install Url, Scopes and Permissions to ApplicationInfo by @Xirado in #1936
- Add UserSnowflake and improve User#fromId by @MinnDevelopment in #2065
- Add CommandInteractionPayload#isGuildCommand by @MinnDevelopment in #2091
- Implement pagination for the guild ban list by @RedDaedalus in #2076
- Replace magic embed count number to constant by @Tais993 in #2048
- Add required & autoComplete in Command.Option to equals() & hashCode() by @itsmefox in #2086
- Return MessageReaction for getReactionX methods by @duncte123 in #2026
Changes
- Dependency upgrades by @Alf-Melmac in #1819
- Improve handling of Role#getPosition and canInteract by @MinnDevelopment in #2085
- Add GuildImpl#invalidate by @MinnDevelopment in #2032
- Handle message related events from unexpected channel types by @MinnDevelopment in #2078
- Correct Activity.listening documentation by @markozajc in #2052
- Replace faulty link with value in replyChoices docs by @SIMULATAN in #2073
- transform hardcoded jump url format into a constant by @caneleex in #2087
Bug Fixes
- Fix NPE when cloning guild role with null icon (v5) by @Tais993 in #2063
- Build the User from data in the Interaction if the User was not cached. by @oliver276 in #2060
- Fix possible ClassCastException when removing reactions in threads by @RoanH in #2069
- Fix rate limiter not shutting down if there is an empty bucket at shutdown by @Vankka in #2080
Removed
- Remove mentioning members with ! by @Tais993 in #2081
- A variety of overloads that accepted string/long/User/Member. Refer to UserSnowflake details above.
Full Changelog: v5.0.0-alpha.9...v5.0.0-alpha.10
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.10")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.10</version>
</dependency>
v5.0.0-alpha.9
Changelog
This release is a follow up hotfix release for 5.0.0-alpha.6 that fixes issues caused by a bug in Discord (discord/discord-api-docs#4557). We felt it was faster to put out a baindaid than to wait for the fix from Discord's side.
Check out the patch notes on 5.0.0-alpha.6 for the cool new stuff.
New Features
N/A
Changes
- Fix issues with event cache by @MinnDevelopment in #2045
- Drop message create for ephemeral messages by @MinnDevelopment in #2043
Removed
- Technically receiving ephemeral messages via
MESSAGE_CREATE
(ThusMessageReceivedEvent
) is now no longer supported.- To be clear, this would be receiving a
MessageReceivedEvent
for an ephemeral message that the bot itself sent.
- To be clear, this would be receiving a
Full Changelog: v5.0.0-alpha.8...v5.0.0-alpha.9
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.9")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.9</version>
</dependency>
v5.0.0-alpha.8 | alpha.6 Hotfix 2: Electric Boogaloo
Changelog
This release is a follow up hotfix release for 5.0.0-alpha.6 that wasn't completely mitigated by the 5.0.0-alpha.7 hotfix.
Check out the patch notes on 5.0.0-alpha.6 for the cool new stuff.
New Features
N/A
Changes
- Restructure message creation to handle a lack of guild_id by @DV8FromTheWorld in #2039
Removed
N/A
Full Changelog: v5.0.0-alpha.7...v5.0.0-alpha.8
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.8")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.8</version>
</dependency>
v5.0.0-alpha.7 | Hotfix for alpha.6
Changelog
This release is a hotfix release for 5.0.0-alpha.6. Check out the patch notes on that version for the cool stuff.
New Features
N/A
Changes
- Make javadocs fail on error by @Sanduhr32 in #2033
- Fixes NPE from uncached users by @oliver276 in #2035
- Make Messages for Interactions properly reference their channels instead of PrivateChannel by @oliver276 in #2038
Removed
N/A
Full Changelog: v5.0.0-alpha.6...v5.0.0-alpha.7
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.7")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.7</version>
</dependency>
v5.0.0-alpha.6 | Attachment Options & Breaking Cleanup
Changelog
This release includes a variety of breaking changes that were needed to either correctly model how Discord models things in their API or to better set us up for future development.
In this version, we added a new pattern for options on commands. You can now use getOption(name[, fallback], resolver)
to easily get any optional arguments for your commands:
public void onSlashCommandInteraction(SlashCommandInteractionEvent event)
{
// name fallback resolver
// null if user is not a member of the guild (fallback not used, since option is mapped to a User instance)
Member member = event.getOption("target", event::getMember, OptionMapping::getAsMember);
// null if fallback is used (getAsUser cannot be null)
User user = event.getOption("target", null , OptionMapping::getAsUser);
// null fallback implied
User nullable = event.getOption("target", OptionMapping::getAsUser); // <- implicit fallback null
// real use-cases:
int days = event.getOption("days", 7, OptionMapping::getAsInt); // optional ban days
String reason = event.getOption("reason", "banned by mod", OptionMapping::getAsString); // optional ban reason
}
You can also now flip the iteration direction for MessageChannel.getIterableHistory. A common request as of late, was to get the first messages of a channel, which can now be accomplished by doing channel.getIterableHistory().reverse().takeAsync(1000)
.
New Features
- Add support for attachment options by @MinnDevelopment in #2001
- Add CommandInteractionPayload#getOption fallback overloads by @MinnDevelopment in #2018
- Add PaginationAction#order by @MinnDevelopment in #1945
- Add Booster to memberCachePolicy by @sweetsofimc in #2022
- Add IGuildChannelContainer and getChannelById(Class, id) by @MinnDevelopment in #1949
Changes
- [Breaking] Change PrivateChannel#getUser to handle API nullability by @oliver276 in #2012
- [Breaking] Make getDefaultChannel return BaseGuildMessageChannel by @MinnDevelopment in #2016
- [Semi-Breaking] Dont override latest message id on deletion event by @ishwi in #2013
- [Breaking] Change some voice Regions and remove VOICE_CHANNEL_REGIONS set by @caneleex in #1962
- Fix OptionData#setAutoComplete logic. by @portlek in #2003
- Fix max file size limit in MessageAction by @Xirado in #2017
- Fix javadoc warnings by @Chew in #1976
- Fix misspelled ErrorResponse enum value by @Xirado in #2031
- Fix missing cache cleanup for news/stage/thread channels by @Mitmocc in #2029
Removed
- Removed excessive non-alphanumeric check by @RobotHanzo in #2021
- [Breaking] Remove StoreChannel by @V-Play-Games in #2011
Full Changelog: v5.0.0-alpha.5...v5.0.0-alpha.6
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.6")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.6</version>
</dependency>
v5.0.0-alpha.5 | Interactions Rework
Changelog
New Features
Interactions Rework
In this release we completely reworked how interactions work in JDA. The changes are significant, but they also bring with them a lot of improvements and new features. I would highly suggest that users take a look at the migration guide provided in the PR to better understand the changes.
Summary:
- Reworks of:
- Slash Commands
- Select Menus
- Buttons
- Introduction of new functionality:
- User Context Commands
- Message Context Commands
- Slash Command Auto Complete
- An improved hierarchy for Interactions
- An improved hierarchy for Components
Changes
- Lots of documentation around threads by @oliver276 in #1838
- Move
requestToSpeak
to StageChannel by @MinnDevelopment in #1978 ThreadChannel#getTimeCreated
is now accurate for Threads created after 2022/01/22 by @caneleex in #1996- Limit new thread message count to 50 by @freya022 in #1980
- ICategorizableChannel#getParentCategoryId now correctly returns
null
if not in a category by @Sanduhr32 in #1993 - Change MessageEmbed#getUrl docs to mention representing the title url by @caneleex in #1975
- Fixes setInvitable in ThreadChannelManager by @oliver276 in #2000
Removed
- N/A
Full Changelog: v5.0.0-alpha.4...v5.0.0-alpha.5
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.5")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.5</version>
</dependency>