Overview
This release primarily adds support for file uploads in modals.
Creating a Modal accepting file uploads
Kotlin
modals.create("modal-id") {
label("Banner image") {
child = AttachmentUpload("banner-file")
}
}Java
modals.create("modal-id")
.addComponents(Label.of("Banner Image", AttachmentUpload.of("banner-file")))
.build()Using the uploaded file
If you use @ModalHandler, you can add a @ModalInput parameter with a List<Message.Attachment> type.
@ModalHandler(name = "modal-id")
fun onModal(event: ModalEvent, @ModalInput("banner-file") bannerAttachments: List<Message.Attachment>) { ... }If you use coroutines, you can use modalEvent[attachmentUpload] instead.
val bannerFileComponent = AttachmentUpload("banner-file")
val modal = modals.create("modal-id") {
label("Banner image") {
child = bannerFileComponent
}
}
// Reply with the modal
val event = modal.await()
val bannerFile = event[bannerFileComponent].asAttachmentList.single()Changes
Dependencies
- Updated to JDA 6.1.0
- Updated to Kotlin 2.2.20
jda-ktx
- Added
customIdto[Type]SelectMenuandTextInputDSLs
Fixes
jda-ktx
- Fixed
LabelDSL not checking if a label was set
Don't hesitate to check out the examples and the wiki.
Full Changelog: v3.0.0-beta.6...v3.0.0-beta.7
Installation
As a reminder, the minimum Java version supported is Java 17.
Kotlin Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("io.github.freya022:BotCommands:3.0.0-beta.7")
}Maven
<dependency>
<groupId>io.github.freya022</groupId>
<artifactId>BotCommands</artifactId>
<version>3.0.0-beta.7</version>
</dependency>