Class ButtonImpl
java.lang.Object
net.dv8tion.jda.internal.components.AbstractComponentImpl
net.dv8tion.jda.internal.components.buttons.ButtonImpl
- All Implemented Interfaces:
ActionComponent
,ActionRowChildComponent
,ActionRowChildComponentUnion
,IDisableable
,Button
,Component
,IComponentUnion
,SectionAccessoryComponent
,SectionAccessoryComponentUnion
,SerializableData
public class ButtonImpl
extends AbstractComponentImpl
implements Button, ActionRowChildComponentUnion, SectionAccessoryComponentUnion
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.components.Component
Component.Type
-
Field Summary
Fields inherited from interface net.dv8tion.jda.api.components.buttons.Button
ID_MAX_LENGTH, LABEL_MAX_LENGTH, URL_MAX_LENGTH
-
Constructor Summary
ConstructorsConstructorDescriptionButtonImpl
(String customId, int uniqueId, String label, ButtonStyle style, String url, SkuSnowflake sku, boolean disabled, Emoji emoji) ButtonImpl
(String customId, String label, ButtonStyle style, boolean disabled, Emoji emoji) ButtonImpl
(String customId, String label, ButtonStyle style, String url, SkuSnowflake sku, boolean disabled, Emoji emoji) ButtonImpl
(DataObject data) -
Method Summary
Modifier and TypeMethodDescriptionboolean
An unique component ID ornull
.getEmoji()
The emoji attached to this button.getLabel()
The visible text on the button, or an empty string if this is aPREMIUM
-style button.getSku()
The target SKU for this button, if it is aPREMIUM
-style Button.getStyle()
The style of this button.getType()
The type of component.int
The unique, numeric identifier of this component.getUrl()
The target URL for this button, if it is aLINK
-Style Button.int
hashCode()
boolean
Whether this action component is disabled.toData()
SerializedDataObject
for this object.toString()
withUniqueId
(int uniqueId) Creates a new component with the provided numeric ID.Methods inherited from class net.dv8tion.jda.internal.components.AbstractComponentImpl
asActionRow, asButton, asContainer, asEntitySelectMenu, asFileDisplay, asMediaGallery, asSection, asSeparator, asStringSelectMenu, asTextDisplay, asTextInput, asThumbnail
Methods inherited from interface net.dv8tion.jda.api.components.ActionComponent
getId
Methods inherited from interface net.dv8tion.jda.api.components.actionrow.ActionRowChildComponentUnion
asButton, asEntitySelectMenu, asStringSelectMenu
Methods inherited from interface net.dv8tion.jda.api.components.buttons.Button
asDisabled, asEnabled, withCustomId, withDisabled, withEmoji, withId, withLabel, withSku, withStyle, withUrl
Methods inherited from interface net.dv8tion.jda.api.components.Component
isMessageCompatible, isModalCompatible
Methods inherited from interface net.dv8tion.jda.api.components.IComponentUnion
isUnknownComponent
Methods inherited from interface net.dv8tion.jda.api.components.attribute.IDisableable
isEnabled
Methods inherited from interface net.dv8tion.jda.api.components.section.SectionAccessoryComponentUnion
asButton, asThumbnail
-
Constructor Details
-
ButtonImpl
-
ButtonImpl
-
ButtonImpl
public ButtonImpl(String customId, String label, ButtonStyle style, String url, SkuSnowflake sku, boolean disabled, Emoji emoji) -
ButtonImpl
public ButtonImpl(String customId, int uniqueId, String label, ButtonStyle style, String url, SkuSnowflake sku, boolean disabled, Emoji emoji)
-
-
Method Details
-
checkValid
-
getType
Description copied from interface:Component
The type of component.- Specified by:
getType
in interfaceComponent
- Returns:
Component.Type
-
withUniqueId
Description copied from interface:Component
Creates a new component with the provided numeric ID.
If no ID is set, Discord will generate IDs incrementally starting from 1 and will not use existing IDs from the same message/modal.- Specified by:
withUniqueId
in interfaceActionComponent
- Specified by:
withUniqueId
in interfaceActionRowChildComponent
- Specified by:
withUniqueId
in interfaceActionRowChildComponentUnion
- Specified by:
withUniqueId
in interfaceButton
- Specified by:
withUniqueId
in interfaceComponent
- Specified by:
withUniqueId
in interfaceIComponentUnion
- Specified by:
withUniqueId
in interfaceIDisableable
- Specified by:
withUniqueId
in interfaceSectionAccessoryComponent
- Specified by:
withUniqueId
in interfaceSectionAccessoryComponentUnion
- Parameters:
uniqueId
- The new ID; must be higher or equal to 1- Returns:
- The new component
-
getCustomId
Description copied from interface:ActionComponent
An unique component ID ornull
.
Some components such as link buttons don't have this.Custom IDs can contain custom data, this is typically used to pass data between a slash command and your button listener.
While this ID is unique and can be retrieved with
ComponentInteraction.getComponentId()
, you should useComponent.getUniqueId()
to identify a component in a single message, such as when replacing components usingComponentTree
orIReplaceable.replace(ComponentReplacer)
.- Specified by:
getCustomId
in interfaceActionComponent
- Returns:
- The component ID or null if not present
- See Also:
-
getUniqueId
public int getUniqueId()Description copied from interface:Component
The unique, numeric identifier of this component.
Can be set manually or automatically assigned by Discord (starting from1
). If it has not been assigned yet, this will return-1
.Note: Older messages may return
0
.- Specified by:
getUniqueId
in interfaceComponent
- Returns:
- The unique identifier of this component, or
-1
if not assigned yet, or0
on older messages
-
getLabel
Description copied from interface:Button
The visible text on the button, or an empty string if this is aPREMIUM
-style button. -
getStyle
Description copied from interface:Button
The style of this button.- Specified by:
getStyle
in interfaceButton
- Returns:
ButtonStyle
-
getUrl
Description copied from interface:Button
The target URL for this button, if it is aLINK
-Style Button. -
getSku
Description copied from interface:Button
The target SKU for this button, if it is aPREMIUM
-style Button. -
getEmoji
Description copied from interface:Button
The emoji attached to this button.
This can be eitherunicode
orcustom
.You can use
Button.withEmoji(Emoji)
to create a button with an Emoji. -
isDisabled
public boolean isDisabled()Description copied from interface:ActionComponent
Whether this action component is disabled.You can use
ActionComponent.asDisabled()
orActionComponent.asEnabled()
to create enabled/disabled instances.- Specified by:
isDisabled
in interfaceActionComponent
- Specified by:
isDisabled
in interfaceIDisableable
- Returns:
- True, if this button is disabled
-
toData
Description copied from interface:SerializableData
SerializedDataObject
for this object.- Specified by:
toData
in interfaceSerializableData
- Returns:
DataObject
-
hashCode
public int hashCode() -
equals
-
toString
-