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>