v5.0.0-beta.23 | Message Polls
MinnDevelopment
released this
21 Apr 09:51
·
74 commits
to master
since this release
Overview
This release includes an updated README, please let us know if you spot any issues with it!
Polls (#2649)
Discord has recently released a new feature on their platform to start and vote in polls. These polls can now be sent in messages:
channel.sendMessage("Hello guys! Check my poll:")
.setPoll(
MessagePollData.builder("Which programming language is better?")
.addAnswer("Java", Emoji.fromFormatted("<:java:1006323566314274856>"))
.addAnswer("Kotlin", Emoji.fromFormatted("<:kotlin:295940257797636096>"))
.build())
.queue()
The poll automatically expires after a set duration, configurable in the MessagePollBuilder
using setDuration. A poll can also be ended manually using endPoll or endPollById.
You can check the poll votes on a message using the new Message#getPoll
:
MessagePoll poll = message.getPoll();
for (MessagePoll.Answer answer : poll.getAnswers()) {
System.out.printf("Poll Answer %s has %d votes\n", answer.getText(), answer.getVotes());
}
Note
The votes for polls are eventually consistent and need to be recounted after the poll ends. You can check whether the votes are validated using MessagePoll#isFinalizedVotes.
New Features
- Add USER_MUST_BE_VERIFIED ErrorResponse by @GitMilchi in #2651
- Update permission enum by @MinnDevelopment in #2654
- Poll support by @MinnDevelopment in #2649
Changes
- Update dependencies and use version catalog by @MinnDevelopment in #2652
Bugs Fixes
Full Changelog: v5.0.0-beta.22...v5.0.0-beta.23
Installation
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.dv8tion:JDA:5.0.0-beta.23")
}
Maven
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.23</version>
</dependency>