Package discord4j.core.object.component
Class Button
- java.lang.Object
-
- discord4j.core.object.component.MessageComponent
-
- discord4j.core.object.component.ActionComponent
-
- discord4j.core.object.component.Button
-
public class Button extends ActionComponent
A message button.- See Also:
- Buttons
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Button.Style
A button's style is what determines its color and whether it has a custom id or a url.-
Nested classes/interfaces inherited from class discord4j.core.object.component.MessageComponent
MessageComponent.Type
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Button
danger(String customId, ReactionEmoji emoji)
Creates adanger
button.static Button
danger(String customId, ReactionEmoji emoji, String label)
Creates adanger
button.static Button
danger(String customId, String label)
Creates adanger
button.Button
disabled()
Creates a new button with the same data as this one, but disabled.Button
disabled(boolean value)
Creates a new button with the same data as this one, but depending on the value param it may be disabled or not.Optional<String>
getCustomId()
Gets the button's custom id.Optional<ReactionEmoji>
getEmoji()
Gets the button's emoji.Optional<String>
getLabel()
Gets button's label.Button.Style
getStyle()
Gets the button's style.Optional<String>
getUrl()
Gets the button's url.boolean
isDisabled()
Gets whether button is disabled.static Button
link(String url, ReactionEmoji emoji)
Creates alink
button.static Button
link(String url, ReactionEmoji emoji, String label)
Creates alink
button.static Button
link(String url, String label)
Creates alink
button.static Button
primary(String customId, ReactionEmoji emoji)
Creates aprimary
button.static Button
primary(String customId, ReactionEmoji emoji, String label)
Creates aprimary
button.static Button
primary(String customId, String label)
Creates aprimary
button.static Button
secondary(String customId, ReactionEmoji emoji)
Creates asecondary
button.static Button
secondary(String customId, ReactionEmoji emoji, String label)
Creates asecondary
button.static Button
secondary(String customId, String label)
Creates asecondary
button.static Button
success(String customId, ReactionEmoji emoji)
Creates asuccess
button.static Button
success(String customId, ReactionEmoji emoji, String label)
Creates asuccess
button.static Button
success(String customId, String label)
Creates asuccess
button.-
Methods inherited from class discord4j.core.object.component.MessageComponent
fromData, getData, getType
-
-
-
-
Method Detail
-
primary
public static Button primary(String customId, String label)
Creates aprimary
button.- Parameters:
customId
- A developer-defined identifier for the button.label
- The text that appears on the button.- Returns:
- A button with the given data.
-
primary
public static Button primary(String customId, ReactionEmoji emoji)
Creates aprimary
button.- Parameters:
customId
- A developer-defined identifier for the button.emoji
- The emoji that appears on the button.- Returns:
- A button with the given data.
-
primary
public static Button primary(String customId, ReactionEmoji emoji, String label)
Creates aprimary
button.- Parameters:
customId
- A developer-defined identifier for the button.emoji
- The emoji that appears on the button.label
- The text that appears on the button.- Returns:
- A button with the given data.
-
secondary
public static Button secondary(String customId, String label)
Creates asecondary
button.- Parameters:
customId
- A developer-defined identifier for the button.label
- The text that appears on the button.- Returns:
- A button with the given data.
-
secondary
public static Button secondary(String customId, ReactionEmoji emoji)
Creates asecondary
button.- Parameters:
customId
- A developer-defined identifier for the button.emoji
- The emoji that appears on the button.- Returns:
- A button with the given data.
-
secondary
public static Button secondary(String customId, ReactionEmoji emoji, String label)
Creates asecondary
button.- Parameters:
customId
- A developer-defined identifier for the button.emoji
- The emoji that appears on the button.label
- The text that appears on the button.- Returns:
- A button with the given data.
-
success
public static Button success(String customId, String label)
Creates asuccess
button.- Parameters:
customId
- A developer-defined identifier for the button.label
- The text that appears on the button.- Returns:
- A button with the given data.
-
success
public static Button success(String customId, ReactionEmoji emoji)
Creates asuccess
button.- Parameters:
customId
- A developer-defined identifier for the button.emoji
- The emoji that appears on the button.- Returns:
- A button with the given data.
-
success
public static Button success(String customId, ReactionEmoji emoji, String label)
Creates asuccess
button.- Parameters:
customId
- A developer-defined identifier for the button.emoji
- The emoji that appears on the button.label
- The text that appears on the button.- Returns:
- A button with the given data.
-
danger
public static Button danger(String customId, String label)
Creates adanger
button.- Parameters:
customId
- A developer-defined identifier for the button.label
- The text that appears on the button.- Returns:
- A button with the given data.
-
danger
public static Button danger(String customId, ReactionEmoji emoji)
Creates adanger
button.- Parameters:
customId
- A developer-defined identifier for the button.emoji
- The emoji that appears on the button.- Returns:
- A button with the given data.
-
danger
public static Button danger(String customId, ReactionEmoji emoji, String label)
Creates adanger
button.- Parameters:
customId
- A developer-defined identifier for the button.emoji
- The emoji that appears on the button.label
- The text that appears on the button.- Returns:
- A button with the given data.
-
link
public static Button link(String url, String label)
Creates alink
button.- Parameters:
url
- The url to navigate to when clicked.label
- The text that appears on the button.- Returns:
- A button with the given data.
-
link
public static Button link(String url, ReactionEmoji emoji)
Creates alink
button.- Parameters:
url
- The url to navigate to when clicked.emoji
- The emoji that appears on the button.- Returns:
- A button with the given data.
-
link
public static Button link(String url, ReactionEmoji emoji, String label)
Creates alink
button.- Parameters:
url
- The url to navigate to when clicked.emoji
- The emoji that appears on the button.label
- The text that appears on the button.- Returns:
- A button with the given data.
-
getStyle
public Button.Style getStyle()
Gets the button's style.- Returns:
- The button's style.
-
getEmoji
public Optional<ReactionEmoji> getEmoji()
Gets the button's emoji.- Returns:
- The button's emoji.
-
getCustomId
public Optional<String> getCustomId()
Gets the button's custom id.- Returns:
- The button's custom id.
-
isDisabled
public boolean isDisabled()
Gets whether button is disabled.- Returns:
- Whether the button is disabled.
-
disabled
public Button disabled()
Creates a new button with the same data as this one, but disabled.- Returns:
- A new disabled button with the same data as this one.
-
disabled
public Button disabled(boolean value)
Creates a new button with the same data as this one, but depending on the value param it may be disabled or not.- Parameters:
value
- True if the button should be disabled otherwise False.- Returns:
- A new possibly disabled button with the same data as this one.
-
-