Package net.dv8tion.jda.api.modals
Class Modal.Builder
java.lang.Object
net.dv8tion.jda.api.modals.Modal.Builder
- Enclosing interface:
Modal
A preconfigured builder for the creation of modals.
-
Method Summary
Modifier and TypeMethodDescriptionaddComponents(Collection<? extends ModalTopLevelComponent> components) Addscomponentsto this modaladdComponents(ModalTopLevelComponent... components) Addscomponentsto this modaladdComponents(ComponentTree<? extends ModalTopLevelComponent> tree) Adds the providedComponentTreeofModalTopLevelComponentsto this modalbuild()Builds and returns theModalReturns a modifiable list of all componentsgetId()Returns the custom idgetTitle()Returns the titleSets the custom id for this modal.Sets the title for this modal.
-
Method Details
-
setId
Sets the custom id for this modal.- Parameters:
customId- Custom id- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException- If the provided id is null, blank, or is longer than 100 characters.
-
setTitle
Sets the title for this modal.- Parameters:
title- The title- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException- If the provided title is null, blank or longer than 45 characters
-
addComponents
Addscomponentsto this modal- Parameters:
components-Componentsto add to the modal, up to 5 total- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException-- If
nullis provided - If any of the provided components are not compatible with modals
- If
- See Also:
-
addComponents
@Nonnull public Modal.Builder addComponents(@Nonnull Collection<? extends ModalTopLevelComponent> components) Addscomponentsto this modal- Parameters:
components-Componentsto add to the modal, up to 5 total- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException-- If
nullis provided - If any of the provided components are not compatible with modals
- If
- See Also:
-
addComponents
@Nonnull public Modal.Builder addComponents(@Nonnull ComponentTree<? extends ModalTopLevelComponent> tree) Adds the providedComponentTreeofModalTopLevelComponentsto this modal- Parameters:
tree- TheComponentTreeto add, containing up to 5 V1 components.- Returns:
- The same builder instance for chaining
- Throws:
IllegalArgumentException-- If
nullis provided - If any of the provided components are not compatible with modals
- If
- See Also:
-
getComponents
Returns a modifiable list of all components- Returns:
- A modifiable list of all components
-
getTitle
Returns the title- Returns:
- the title
-
getId
Returns the custom id- Returns:
- the id
-
build
Builds and returns theModal- Returns:
- A Modal
- Throws:
IllegalArgumentException-- If no components are added
- If more than 5 component layouts are added
-