Skip to content

v6.0.0-rc.5 | Modal Components and Serialization

Pre-release
Pre-release
Compare
Choose a tag to compare
@MinnDevelopment MinnDevelopment released this 14 Sep 13:57
c606efb

Overview

This release adds support for more components in Modals and reintroduces serialization for all components.

Modal Components (#2913)

In the previous release, support for StringSelectMenu within modals has been added. This is now expanded to also include EntitySelectMenu and TextDisplay components.

The TextDisplay component has full markdown support, which allows you to create more fleshed out modals than before:

Modal.create("modal", "Role Request Form")
    .addComponents(
        TextDisplay.of("""
            **Welcome!**
            
            Please read the following before continuing:
            
            - Select a user to request a role for
            - A moderator will review your request
            - Abuse of this system may result in penalties
            """),
        Label.of(
            "Role",
            EntitySelectMenu.create("role-select", SelectTarget.ROLE).build()
        )
    )
    .build();

Results in this modal being shown:

image

Serialization and Deserialization (#2906)

We've added a new ComponentSerializer and ComponentDeserializer, which can be used to serialize components into DataObject and FileUpload instances. This replaces the previous component.toData() from JDA 5, with a new serializer.serialize(component).

Example:

ComponentSerializer serializer = new ComponentSerializer();

List<DataObject> serializedComponents = serializer.serializeAll(message.getComponents());
List<FileUpload> files = serializer.getFileUploads(message.getComponents());

// use serialized component
// ...

// Or deserialize them if you get them from another source
// Here we pass in the List<FileUpload> used by the components
ComponentDeserializer deserializer = new ComponentDeserializer(files);
MessageComponentTree tree = deserializer.deserializeAsTree(MessageComponentTree.class, serializedComponents);

New Features

Changes

  • Deprecate and replace TextInput.Builder#setId with setCustomId by @freya022 in #2909

Bug Fixes

  • Remove unnecessary escaping while creating a masked link by @Alf-Melmac in #2910

Full Changelog: v6.0.0-rc.4...v6.0.0-rc.5

Installation

Gradle

repositories {
    mavenCentral()
}
dependencies {
    implementation("net.dv8tion:JDA:6.0.0-rc.5")
}

Maven

<dependency>
    <groupId>net.dv8tion</groupId>
    <artifactId>JDA</artifactId>
    <version>6.0.0-rc.5</version> 
</dependency>