Class Component<S extends Component<S,T,B,D>, T extends ActionComponent, B, D extends ComponentDefinition<T>>

java.lang.Object
io.github.kaktushose.jdac.dispatching.reply.Component<S,T,B,D>
Type Parameters:
S - the concrete subtype of Component
T - the type of ActionComponent the ComponentDefinition represents
B - the type of builder the ActionComponent uses
D - the type of ComponentDefinition this Component represents
All Implemented Interfaces:
ActionComponent, ActionRowChildComponent, ActionRowChildComponentUnion, ICustomId, IDisableable, Component, IComponentUnion, SectionAccessoryComponent, SectionAccessoryComponentUnion
Direct Known Subclasses:
ButtonComponent, SelectMenuComponent, UnspecificComponent

public abstract sealed class Component<S extends Component<S,T,B,D>, T extends ActionComponent, B, D extends ComponentDefinition<T>> extends Object implements ActionComponent, ActionRowChildComponentUnion, SectionAccessoryComponentUnion permits ButtonComponent, UnspecificComponent, SelectMenuComponent<S,T,B,D>

Represents a component, namely Button, StringMenu or EntityMenu, that should be added to a reply.

Also holds the following two settings:

enabled:

to enable or disable the component

independent:

whether the component should be executed in the same Runtime as the command it is bound to or not. If true, every component interaction will create a new Runtime. Furthermore, the component cannot expire and will always get executed, even after a bot restart.

Example:

@SlashCommand("example command")
public void onCommand(CommandEvent event) {
    event.with().components(Components.of(true, false, "onButton")).reply();
}

Component type specific implementations

If using one of:

a specific implementation is returned which allows for further modification.

Example without localization

This example overrides the buttons label with "Modified Label"

@Command("example command")
public void onCommand(CommandEvent event) {
    event.with().components(Components.button("onButton")
                    .label("Modified Label"))
                .reply();
}

Example with localization

@Bundle("example")
@Command("example command")
public void onCommand(CommandEvent event, User user) {
    event.with().components(Components.button("onButton")
                    .label("label", I18n.entry("name", user.getName())))
                .reply();
}
See Also: