Releases: discord-jda/JDA
v5.0.0-beta.7 | Customize Rate-Limiter
Overview
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.
Rate-Limiter Customization (#2307)
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.
Member Flags (#2417)
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();
Features
- Add rate-limiter customization by @MinnDevelopment in #2307
- Add support for member flags by @MinnDevelopment in #2417
Changes
- Remove AccountType by @MinnDevelopment in #2420
- Handle new channel field on interactions by @MinnDevelopment in #2436
Bug Fixes
- Fix channel manager not using right type by @MinnDevelopment in #2428
Full Changelog: v5.0.0-beta.6...v5.0.0-beta.7
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.7")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.7</version>
</dependency>
v5.0.0-beta.6 | Messages in Stage Channels
Overview
This release adds support for messages and interactions inside stage channels.
New Features
- Add default_forum_layout for Forum Channel by @Mysterious-Dev in #2407
- Support messages in stage channels by @MinnDevelopment in #2399
Changes
- Count reply mentions in bag getters by @MinnDevelopment in #2409
Bug Fixes
Full Changelog: v5.0.0-beta.5...v5.0.0-beta.6
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.6")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.6</version>
</dependency>
v5.0.0-beta.5 | Hotfix voice connection issues
Overview
This is a minor release with some important bug fixes. All bots relying on voice connections should apply this update as soon as possible.
Changes
- Add new message types by @MinnDevelopment in #2371
Bug Fixes
- Catch parsing exception for scheduled events by @MinnDevelopment in #2401
- Catch errors thrown during login validation by @MinnDevelopment in #2406
- Use 74 byte handshake by @MinnDevelopment in #2412
Full Changelog: v5.0.0-beta.4...v5.0.0-beta.5
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.5")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.5</version>
</dependency>
v5.0.0-beta.4 | Audit Log Events and Silent Messages
Overview
This release adds support for recent Discord features, such as linked roles and silent messages. We also improved the user experience for shutting down, which should come in handy for anyone building reloadable plugins.
Add GuildAuditLogEntryCreateEvent (#2380)
Discord has finally introduced an event for new audit log entries. This can be used for keeping track of all kinds of moderation relevant activity in a guild. However, to receive this event you must have the View Audit Logs permission and enable the GUILD_MODERATION
intent (formerly GUILD_BANS
).
Silent Messages (#2392)
You can now send and receive messages which do not trigger desktop and mobile push notifications. This is done in the client by prefixing a message with @silent
. In JDA you can use setSuppressedNotifications(true)
to achieve the same. Note that @silent
is not the correct way to create these messages with a bot, as it is a client only feature.
You can check the release pull request for more information: discord/discord-api-docs#5910
Await Shutdown (#2269)
The shutdown logic has adapted to allow more consistent behavior. We've introduced jda.awaitShutdown()
as a way to allow blocking until all JDA subsystems reach completion. Note that this might take a long time, depending on how long your RestAction queue is at the time.
The recommended way to gracefully shutdown is to define a maximum wait threshold and use it to cancel requests after some time:
// Initating the shutdown, this closes the gateway connection and subsequently closes the requester queue
jda.shutdown();
// Allow at most 10 seconds for remaining requests to finish
if (!jda.awaitShutdown(Duration.ofSeconds(10))) { // returns true if shutdown is graceful, false if timeout exceeded
jda.shutdownNow(); // Cancel all remaining requests, and stop thread-pools
jda.awaitShutdown(); // Wait until shutdown is complete (indefinitely)
}
In order to save CPU time, we make use of conditional variables for all of our wait loops internally. This is much more efficient than using sleep polling, like suggested in the past.
New Features
- Add GuildAuditLogEntryCreateEvent by @MinnDevelopment in #2380
- Add
SUPPRESS_NOTIFICATIONS
flag for message by @Mysterious-Dev in #2393 - Add thread message positions by @freya022 in #2366
- Necessary additions for role subscriptions by @MinnDevelopment in #2375
Changes
- Improve conditional waiting and shutdown handling by @MinnDevelopment in #2269
- Add Modal.Builder#addComponents by @MinnDevelopment in #2388
Full Changelog: v5.0.0-beta.3...v5.0.0-beta.4
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.4")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.4</version>
</dependency>
v5.0.0-beta.3
Overview
Small release to fix a few bugs and introduce support for new API features.
GIF Sticker Support
Discord is adding support to create stickers with GIFs in the future. This release already covers support for receiving and creating them in advance of the rollout. Note that it will currently not work since the API for GIF stickers has not yet been deployed, in the meantime you will receive an invalid asset error.
Reverse Audit-Log Iteration
You can now use PaginationAction#reverse
on Guild#retrieveAuditLogs
. This allows you to iterate from the oldest entry to the newest one.
Removing Options/Subcommands from SlashCommands
You can now use conditional remove operations on SlashCommandData
to remove options and slash commands.
Example:
SlashCommandData command = SlashCommandData.fromData(json); // parsing an existing command from json
command.removeOptions(o -> o.isRequired()); // Removing all required options
Note: You still have to pass this updated command to discord using upsertCommand
or updateCommands
!
New Features
- Add support for gif stickers by @MinnDevelopment in #2377
- Add support for reverse audit-log iteration by @MinnDevelopment in #2370
- Improve implementation of command data by @MinnDevelopment in #2258
Changes
- Replace lock code with atomic int by @MinnDevelopment in #2359
- Update okhttp to 4.10.0 by @MinnDevelopment in #2382
- Change handling of speaking updates in voice connections by @MinnDevelopment in #2240
Bug Fixes
- Fix welcome channel parsing when no emoji is used by @freya022 in #2356
- Fix issues with ChannelManager#setPinned and setTagRequired by @MinnDevelopment in #2364
Full Changelog: v5.0.0-beta.2...v5.0.0-beta.3
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.3")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.3</version>
</dependency>
v5.0.0-beta.2
Overview
Small release to fix a few bugs and typing issues.
Support for Welcome Screens (#2264 / #1989)
You can now retrieve and manage the welcome screen of a guild. To modify a welcome screen, you can use Guild#modifyWelcomeScreen:
TextChannel rules = guild.getTextChannelsByName("rules", true).get(0);
ForumChannel help = guild.getForumChannelsByName("help-forum", true).get(0);
guild.modifyWelcomeScreen()
.setDescription("Welcome to our cool guild!")
.setWelcomeChannels(
GuildWelcomeScreen.Channel.of(rules, "Read our rules"),
GuildWelcomeScreen.Channel.of(help, "Ask for help in our forum", Emoji.fromUnicode("U+1F4AC"))
)
.queue();
New Features
- Add generic slowmode channel manager to slowmode channel interface by @Sanduhr32 in #2348
- Add guild welcome screens by @freya022 in #2264
Changes
- Make StringSelectMenuImpl#getOptions return unmodifiable list by @dkim19375 in #2344
- Bump jackson-core and jackson-databind from 2.13.2 to 2.14.1 by @MelaineGerard in #2337
Bug Fixes
- Remove code to rename guild_member to member by @MinnDevelopment in #2341
- Fix bug when updating a scheduled events location by @Mitmocc in #2349
Full Changelog: v5.0.0-beta.1...v5.0.0-beta.2
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.2")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.2</version>
</dependency>
v5.0.0-beta.1 | Time to update
Overview
We finally made it 🎉 BETA 🎉 ! This concludes the major rewrites and large breaking changes of JDA version 5. With this release, we feel confident that people can rely on updates no longer requiring major rewrites of their codebases in the foreseeable future (praying to the API gods).
There will likely be some effort made to provide a full migration guide for anyone still stuck on version 4. It is recommended to update to version 5 as soon as possible. Version 4 is officially reaching EOL in the first quarter of 2023, and will stop working soon after due to the gateway version 8 being discontinued.
You can join our discord server, where we have a channel called #jda5-changes with a brief changelog for all the breaking changes.
We've also started accepting donations via Open Collective. Any donation are greatly appreciated.
Age-Restricted Commands (#2325)
You can now create NSFW (or age-restricted) commands, which are only usable in age-restricted channels.
Commands.slash("nsfw", "Something nsfw").setNSFW(true)
Channel Ordering (#2320)
The implementation for GuildChannel#compareTo
has been adjusted to support comparing channels of different types. This can be used to figure out the order of channels within the channel list. For instance, if you compare a channel to the category it is in, it will be ordered lower than the category.
This also extends to Guild#getChannels
, which now uses the updated compareTo
implementation for ordering. As such, you can also order a sublist of all channels yourself, by using list.sort()
. This even works with thread channels.
New Features
- Add application_id support for received messages by @Almighty-Satan in #2335
- Add support for age-restricted (nsfw) commands by @MinnDevelopment in #2325
- Implement "ACTIVE_DEVELOPER" UserFlag by @DynxstyGIT in #2326
- Add slash command mentions by @freya022 in #2251
Changes
- Implement thread member pagination by @MinnDevelopment in #2338
- More v5 documentation by @Sanduhr32 in #2296
- Improve GuildChannel#getPosition and Guild#getChannels by @MinnDevelopment in #2320
- Remove archived threads from cache by @MinnDevelopment in #2322
- Forward shutdown reason to awaitStatus exception by @MinnDevelopment in #2268
- Make Widget an interface and move it to it's own file by @Almighty-Satan in #2295
Bug Fixes
- Fix some lock issues by @MinnDevelopment in #2339
- Remove outdated feature check for private threads by @RedDaedalus in #2336
- Fix recursive json object created in mention parsing by @MinnDevelopment in #2334
- Fix handling of empty select menu interactions by @MinnDevelopment in #2330
- Use deep copy for layout components when applying message data by @freya022 in #2236
- Fix JDA#retrieveWebhookById by @MinnDevelopment in #2319
- [Bugfix] Mark ForumChannel as a TopicChannelMixin by @Sanduhr32 in #2317
- Fix MemberCacheViewImpl#getElementsWithRoles and Guild#findMembersWithRoles ignoring the public role by @Almighty-Satan in #2297
- Fix GuildSticker#retrieveOwner by @MinnDevelopment in #2316
- Fix NullPointerException in GuildManagerImpl#addFeatures and GuildManagerImpl#removeFeatures by @Almighty-Satan in #2314
Full Changelog: v5.0.0-alpha.22...v5.0.0-beta.1
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.1")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.1</version>
</dependency>
v5.0.0-alpha.22
Overview
This is most likely the final alpha release. The current plan is to merge a few more breaking changes, and address some remaining TODOs before finally bumping to beta! Stay tuned.
Implement new select menus (#2287)
Discord has introduced new select menu component types, which support selecting mentionable entities like User
/Role
/Channel
. With this release we are introducing a small breaking change to the SelectMenu
type:
StringSelectMenu
is the old select menu, used for custom string choicesEntitySelectMenu
is the new select menu, used for mentionable entities
And you use the StringSelectInteractionEvent
and EntitySelectInteractionEvent
to handle them.
Ability to disable/pause invites of a guild (#2222)
Recently, Discord added a new moderation feature to pause the invites of a guild, including vanity invites. This is usually done using the Pause Invites button in the guild settings.
You can now do this using the GuildManager
via setInvitesDisabled(true)
.
Scheduled Events (#2047)
This is rather late, but you can now handle and create scheduled events. To create a scheduled event you can use one of the createScheduledEvent
overloads in Guild
:
- Use
createScheduledEvent(name, channel, time)
to create a local event to take place in a specific voice or stage channel - Use
createScheduledEvent(name, location, startTime, endTime)
to create an external event, such as a concert or similar
New Features
- Add GuildManager#setFeatures by @MinnDevelopment in #2222
- Add support for guild scheduled events v2 by @Mitmocc in #2047
- Implement new select menus by @MinnDevelopment in #2287
Changes
- Retain sort order for ThreadChannel#getAppliedTags by @MinnDevelopment in #2278
- FileProxy: additional checks on existing files by @freya022 in #2293
- Put "options" between command path and options, same for choices by @freya022 in #2261
- Move ModalInteraction into correct package by @Xirado in #2282
- Improve
toString
methods by @freya022 in #2273 - Check for empty token in AuthorizationConfig, instead of JDAImpl by @freya022 in #2230
- Improve channel update handling by @MinnDevelopment in #2255
Bug Fixes
- Make ForumTag extend ForumTagSnowflake by @MinnDevelopment in #2276
- Handle emoji_id sometimes being 0 instead of null by @MinnDevelopment in #2279
Full Changelog: v5.0.0-alpha.21...v5.0.0-alpha.22
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.22")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.22</version>
</dependency>
v5.0.0-alpha.21 | Small Event Changes
Overview
Almost ready for beta. This release changes a few event names and introduces a new interface GenericSessionEvent
. With this, almost every breaking change that we had planned is completed. There will likely only be one more alpha release before bumping to beta.
Event Changes (#1952)
Events related to the active gateway session / main socket now have a common abstraction called GenericSessionEvent
. We also changed a few event names for better clarity:
Old | New |
---|---|
DisconnectEvent | SessionDisconnectEvent |
ReconnectedEvent | SessionRecreateEvent |
ResumedEvent | SessionResumeEvent |
All the session related events are now in a common package at net.dv8tion.jda.api.events.session
, this also includes some breaking package changes for a few commonly used events like ReadyEvent
.
Additionally, events for voice channels of guild members have been changed slightly. Previously, we provided 3 separate voice channel update events:
- GuildVoiceJoinEvent
- GuildVoiceLeaveEvent
- GuildVoiceMoveEvent
Due to the confusing nature of these events, we have decided to instead only provide a single GuildVoiceUpdateEvent. This new event provides the old and new channel, which can each be null to indicate either a leave (null new channel) or join (null old channel).
Changes
- Update event hierarchy by @MinnDevelopment in #1952
- Make annotation dependencies compileOnly by @MinnDevelopment in #2249
Bug Fixes
- Fix check for ChannelAction#setCategory by @MinnDevelopment in #2259
- Fix some checks not throwing the intended exception by @MinnDevelopment in #2260
- fix: Use correct "flags" field for message create action by @RedDaedalus in #2272
- Handle newly_created gracefully by @MinnDevelopment in #2254
- Fix manager docs by @freya022 in #2271
- Add missing annotations on ThreadChannel by @MinnDevelopment in #2274
Full Changelog: v5.0.0-alpha.20...v5.0.0-alpha.21
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.21")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.21</version>
</dependency>
v5.0.0-alpha.20 | Forum channel support
Overview
Discord is currently rolling out forums to all community guilds. This release adds support for these channels in JDA.
Forum support (#2184)
To use a forum channel, you must create a forum post. Posts are simply public ThreadChannels
with a starter message. To create a post, instead of using the usual createThreadChannel
, you must use createForumPost
:
forum.createForumPost("Post Title Here", new MessageCreateBuilder()
.addContent("# Header\n")
.addContent("This is my first forum post!")
.build()
).queue(post -> {
Message message = post.getMessage();
ThreadChannel thread = post.getThreadChannel();
thread.sendMessage("Followup message").queue();
});
To create such a post, the bot must have Permission.MESSAGE_SEND
in the forum channel. The client refers to this permission as Create Posts.
AudioChannel improvements (#2252)
As of this release, AudioChannel
extends StandardGuildChannel
instead of GuildChannel
. This allows for a lot more features directly on the abstract interface, rather than having to cast down to voice or stage channels.
- Invites
- Category getter
- Permissions
- Positions
- Copying
New Features
- Add support for forum channels by @MinnDevelopment in #2184
- Added RestAction#onSuccess by @Zabuzard in #2227
Changes
- Improve usability of AudioChannel by @MinnDevelopment in #2252
Full Changelog: v5.0.0-alpha.19...v5.0.0-alpha.20
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.20")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.20</version>
</dependency>