Class SequencedTextDisplay
- All Implemented Interfaces:
LocalizedComponent, SequencedComponent<TextDisplay>, Component, ContainerChildComponent, ContainerChildComponentUnion, IComponentUnion, MessageTopLevelComponent, MessageTopLevelComponentUnion, ModalTopLevelComponent, ModalTopLevelComponentUnion, SectionContentComponent, SectionContentComponentUnion, TextDisplay, SerializableData
A TextDisplay implementation that is backed by a SequencedCollection and allows its content to be
appended in sequence.
The add(String, Entry...) methods of this class will first append to an internally stored
SequencedCollection. When getContent() or toData() gets called, this collection gets unfolded and
all TextDisplays are joined into one. textDisplays() will return the TextDisplays directly as stored in the
SequencedCollection.
Usage inside SequencedContainers
If used inside a SequencedContainer, the TextDisplays don't get joined and each TextDisplay will be added
individually in sequence.
Localization
This TextDisplay implementation also supports localization. When [#getContent()()] or toData() is called, the
content of this TextDisplay is localized via ComponentResolver. Use entries(Entry...) to provide
additional Entries outside the add(String, Entry...) methods.
Usage outside JDA-Commands
TextDisplay.of(String) uses the JDACIntrospection API to access a Resolver and the user locale. This
means, the static of factory method is only usable in JDACScope.PREPARATION. If you want to use this class outside
JDA-Commands call the constructor and pass the Resolver as well as the Locale manually.
var textDisplay = new SequencedTextDisplay(resolver, locale, TextDisplay.of("Hello World!));
-
Nested Class Summary
Nested classes/interfaces inherited from interface Component
Component.Type -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newSequencedTextDisplay.SequencedTextDisplay(Resolver<String> resolver, Locale locale, TextDisplay header, Entry... entries) Constructs a newSequencedTextDisplay.SequencedTextDisplay(Resolver<String> resolver, DiscordLocale locale, String content, Entry... entries) Constructs a newSequencedTextDisplay.SequencedTextDisplay(Resolver<String> resolver, DiscordLocale locale, TextDisplay header, Entry... entries) Constructs a newSequencedTextDisplay. -
Method Summary
Modifier and TypeMethodDescriptionAppends aTextDisplayto the end of this container.add(TextDisplay display, Entry... entries) Appends aTextDisplayto the end of this container.addAll(Collection<TextDisplay> component, Entry... entries) Appends all the elements in the specified collection to the end of this component.Adds aTextDisplayto this container as the firstTextDisplayof this container.addFirst(TextDisplay display, Entry... entries) Adds aTextDisplayto this container as the firstTextDisplayof this container.Adds aTextDisplayto this container as the lastTextDisplayof this container.addLast(TextDisplay display, Entry... entries) Adds aTextDisplayto this container as the lastTextDisplayof this container.voidSets the delimiter used for joining theTextDisplays.Adds Entries to use for localization.entries(Collection<Entry> entries) Adds Entries to use for localization.Gets the content of allTextDisplays of this container joined together.locale()Gets theLocalethis container will be localized inSets theLocalethis component will be localized inlocale(DiscordLocale locale) Sets theLocalethis component will be localized instatic SequencedTextDisplayConstructs a newSequencedTextDisplayfrom the givenString.static SequencedTextDisplayof(TextDisplay header, Entry... entries) Constructs a newSequencedTextDisplayfrom the givenTextDisplay.Gets allTextDisplays of this container.toData()SerializedDataObjectfor this container.withContent(String content) Replaces allTextDisplays of thisSequencedTextDisplaywith the specified content.withContent(String content, Entry... entries) Replaces allTextDisplays of thisSequencedTextDisplaywith the specified content.withContent(TextDisplay display, Entry... entries) withUniqueId(int uniqueId) Methods inherited from class net.dv8tion.jda.internal.components.textdisplay.TextDisplayImpl
equals, getType, getUniqueId, hashCode, toStringMethods inherited from class net.dv8tion.jda.internal.components.AbstractComponentImpl
asActionRow, asAttachmentUpload, asButton, asCheckbox, asCheckboxGroup, asContainer, asEntitySelectMenu, asFileDisplay, asLabel, asMediaGallery, asRadioGroup, asSection, asSeparator, asStringSelectMenu, asTextDisplay, asTextInput, asThumbnail, toComponentTypeMethods inherited from interface Component
isMessageCompatible, isModalCompatibleMethods inherited from interface ContainerChildComponentUnion
asActionRow, asFileDisplay, asMediaGallery, asSection, asSeparator, asTextDisplayMethods inherited from interface IComponentUnion
isUnknownComponentMethods inherited from interface MessageTopLevelComponentUnion
asActionRow, asContainer, asFileDisplay, asMediaGallery, asSection, asSeparator, asTextDisplayMethods inherited from interface ModalTopLevelComponentUnion
asLabel, asTextDisplayMethods inherited from interface SectionContentComponentUnion
asTextDisplay
-
Constructor Details
-
SequencedTextDisplay
public SequencedTextDisplay(Resolver<String> resolver, DiscordLocale locale, String content, Entry... entries) Constructs a newSequencedTextDisplay.- Parameters:
resolver- theResolverto use for localizationlocale- the locale this container will be localized tocontent- theStringto use for the firstTextDisplayof this containerentries- the Entries used for localization
-
SequencedTextDisplay
public SequencedTextDisplay(Resolver<String> resolver, DiscordLocale locale, TextDisplay header, Entry... entries) Constructs a newSequencedTextDisplay.- Parameters:
resolver- theResolverto use for localizationlocale- the locale this container will be localized toheader- the firstTextDisplayof this containerentries- the Entries used for localization
-
SequencedTextDisplay
public SequencedTextDisplay(Resolver<String> resolver, Locale locale, String content, Entry... entries) Constructs a newSequencedTextDisplay.- Parameters:
resolver- theResolverto use for localizationlocale- the locale this container will be localized tocontent- theStringto use for the firstTextDisplayof this containerentries- the Entries used for localization
-
SequencedTextDisplay
public SequencedTextDisplay(Resolver<String> resolver, Locale locale, TextDisplay header, Entry... entries) Constructs a newSequencedTextDisplay.- Parameters:
resolver- theResolverto use for localizationlocale- the locale this container will be localized toheader- the firstTextDisplayof this containerentries- the Entries used for localization
-
-
Method Details
-
of
Constructs a new
SequencedTextDisplayfrom the givenString.This method can only be used inside events or in methods annotated with
IntrospectionAccess.- Parameters:
content- theStringto use for the firstTextDisplayof this containerentries- the Entries used for localization- Throws:
IllegalStateException- if theJDACScope.PREPARATIONisn't accessible.
-
of
Constructs a new
SequencedTextDisplayfrom the givenTextDisplay.This method can only be used inside events or in methods annotated with
IntrospectionAccess.- Parameters:
header- the firstTextDisplayof this containerentries- the Entries used for localization- Throws:
ReplyException- if theJDACScope.PREPARATIONisn't accessible.
-
add
Appends aTextDisplayto the end of this container.- Parameters:
content- theStringto use for theTextDisplayentries- the Entries used for localization- Returns:
- this instance for fluent interface
-
add
Appends aTextDisplayto the end of this container.- Specified by:
addin interfaceSequencedComponent<TextDisplay>- Parameters:
display- theTextDisplayto addentries- the Entries used for localization- Returns:
- this instance for fluent interface
-
addFirst
Adds aTextDisplayto this container as the firstTextDisplayof this container.- Parameters:
content- theStringto use forTextDisplayentries- the Entries used for localization- Returns:
- this instance for fluent interface
-
addFirst
Adds aTextDisplayto this container as the firstTextDisplayof this container.- Specified by:
addFirstin interfaceSequencedComponent<TextDisplay>- Parameters:
display- theTextDisplayto addentries- the Entries used for localization- Returns:
- this instance for fluent interface
-
addLast
Adds aTextDisplayto this container as the lastTextDisplayof this container.- Parameters:
content- theStringto use for theTextDisplayentries- the Entries used for localization- Returns:
- this instance for fluent interface
-
addLast
Adds aTextDisplayto this container as the lastTextDisplayof this container.- Specified by:
addLastin interfaceSequencedComponent<TextDisplay>- Parameters:
display- theTextDisplayto addentries- the Entries used for localization- Returns:
- this instance for fluent interface
-
addAll
Description copied from interface:SequencedComponentAppends all the elements in the specified collection to the end of this component.- Specified by:
addAllin interfaceSequencedComponent<TextDisplay>- Parameters:
component- the elements to addentries- the Entries used for localization- Returns:
- this instance for fluent interface
-
locale
Description copied from interface:LocalizedComponentGets theLocalethis container will be localized in- Specified by:
localein interfaceLocalizedComponent- Returns:
- the
Locale
-
locale
Description copied from interface:LocalizedComponentSets theLocalethis component will be localized in- Specified by:
localein interfaceLocalizedComponent- Parameters:
locale- the newDiscordLocaleto use for localization- Returns:
- this instance for fluent interface
-
locale
Description copied from interface:LocalizedComponentSets theLocalethis component will be localized in- Specified by:
localein interfaceLocalizedComponent- Parameters:
locale- the newLocaleto use for localization- Returns:
- this instance for fluent interface
-
entries
Description copied from interface:LocalizedComponentAdds Entries to use for localization.- Specified by:
entriesin interfaceLocalizedComponent- Parameters:
entries- the Entries- Returns:
- this instance for fluent interface
-
entries
Description copied from interface:LocalizedComponentAdds Entries to use for localization.- Specified by:
entriesin interfaceLocalizedComponent- Parameters:
entries- the Entries- Returns:
- this instance for fluent interface
-
delimiter
Sets the delimiter used for joining theTextDisplays. Defaults to\n.- Parameters:
delimiter- the delimiter to use, seeString.join(CharSequence, CharSequence...)
-
textDisplays
Gets allTextDisplays of this container.- Returns:
- the
TextDisplays of this container
-
toData
Serialized
DataObjectfor this container.This will join all
TextDisplays of this container into one.- Specified by:
toDatain interfaceSerializableData- Overrides:
toDatain classnet.dv8tion.jda.internal.components.textdisplay.TextDisplayImpl- Returns:
- the
DataObject
-
getContent
Gets the content of allTextDisplays of this container joined together.- Specified by:
getContentin interfaceTextDisplay- Overrides:
getContentin classnet.dv8tion.jda.internal.components.textdisplay.TextDisplayImpl- Returns:
- the joined content
-
withContent
Replaces allTextDisplays of thisSequencedTextDisplaywith the specified content.- Specified by:
withContentin interfaceTextDisplay- Overrides:
withContentin classnet.dv8tion.jda.internal.components.textdisplay.TextDisplayImpl- Parameters:
content- The new content- Returns:
- The new
SequencedTextDisplay
-
withContent
Replaces allTextDisplays of thisSequencedTextDisplaywith the specified content.- Parameters:
content- The new contententries- the Entries used for localization- Returns:
- The new
SequencedTextDisplay
-
withContent
- Parameters:
display- The newTextDisplayentries- the Entries used for localization- Returns:
- The new
SequencedTextDisplay
-
withUniqueId
- Specified by:
withUniqueIdin interfaceComponent- Specified by:
withUniqueIdin interfaceContainerChildComponent- Specified by:
withUniqueIdin interfaceContainerChildComponentUnion- Specified by:
withUniqueIdin interfaceIComponentUnion- Specified by:
withUniqueIdin interfaceMessageTopLevelComponent- Specified by:
withUniqueIdin interfaceMessageTopLevelComponentUnion- Specified by:
withUniqueIdin interfaceModalTopLevelComponent- Specified by:
withUniqueIdin interfaceModalTopLevelComponentUnion- Specified by:
withUniqueIdin interfaceSectionContentComponent- Specified by:
withUniqueIdin interfaceSectionContentComponentUnion- Specified by:
withUniqueIdin interfaceTextDisplay- Overrides:
withUniqueIdin classnet.dv8tion.jda.internal.components.textdisplay.TextDisplayImpl
-