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>