v5.0.0-alpha.11 | Modals
DV8FromTheWorld
released this
25 Apr 19:46
·
405 commits
to master
since this release
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>