Class ComponentEvent

java.lang.Object
io.github.kaktushose.jdac.dispatching.events.Event<net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent>
io.github.kaktushose.jdac.dispatching.events.ReplyableEvent<net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent>
io.github.kaktushose.jdac.dispatching.events.ModalReplyableEvent<net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent>
io.github.kaktushose.jdac.dispatching.events.interactions.ComponentEvent
All Implemented Interfaces:
net.dv8tion.jda.api.entities.ISnowflake, net.dv8tion.jda.api.interactions.Interaction

public final class ComponentEvent extends ModalReplyableEvent<net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent>
This class is a subclass of Event. It provides additional features for replying to a GenericComponentInteractionCreateEvent.
See Also:
  • Constructor Details

    • ComponentEvent

      public ComponentEvent()
  • Method Details

    • jdaEvent

      public <T extends net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent> T jdaEvent(Class<T> type)
      Returns the underlying GenericComponentInteractionCreateEvent and casts it to the given type.
      Type Parameters:
      T - a subtype of GenericComponentInteractionCreateEvent
      Parameters:
      type - a subtype of GenericComponentInteractionCreateEvent, namely ButtonInteractionEvent, EntitySelectInteractionEvent or StringSelectInteractionEvent
      Returns:
      T the event
    • deferReply

      public void deferReply(boolean ephemeral)
      Description copied from class: ReplyableEvent

      Acknowledge this interaction and defer the reply to a later time.

      This will send a <Bot> is thinking... message in chat that will be updated later. This will use the passed boolean to set the ephemeral flag. If your initial deferred message is ephemeral it cannot be made non-ephemeral later. Use ReplyableEvent.deferReply() to use the InteractionDefinition.ReplyConfig for the ephemeral flag.

      You only have 3 seconds to acknowledge an interaction!

      When the acknowledgement is sent after the interaction expired, you will receive ErrorResponse.UNKNOWN_INTERACTION.

      Use ReplyableEvent.reply(String, Entry...) to reply directly.

      Specified by:
      deferReply in class ReplyableEvent<net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent>
      Parameters:
      ephemeral - yes
    • deferEdit

      public void deferEdit()

      No-op acknowledgement of this interaction.

      This tells discord you intend to update the message that the triggering component is a part of instead of sending a reply message. You are not required to actually update the message, this will simply acknowledge that you accepted the interaction.

      You only have 3 seconds to acknowledge an interaction!

      When the acknowledgement is sent after the interaction expired, you will receive ErrorResponse.UNKNOWN_INTERACTION.

      Use ReplyableEvent.reply(String, Entry...) to edit it directly.

    • removeComponents

      public void removeComponents()

      Removes all components from the original message.

      The original message is the message, from which this event (interaction) originates. For example if this event is a ButtonEvent, the original message will be the message to which the pressed button is attached to.

    • with

      Description copied from class: ReplyableEvent

      Entry point for configuring a reply.

      Returns a new ConfigurableReply that can be used to append components or override reply settings.

      Overrides:
      with in class ReplyableEvent<net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent>
      Returns:
      a new ConfigurableReply
      See Also:
    • reply

      public net.dv8tion.jda.api.entities.Message reply(net.dv8tion.jda.api.components.replacer.ComponentReplacer replacer, Entry... placeholder)

      Acknowledgement of this event with the V2 Components of the original reply. Will also apply the passed ComponentReplacer before sending the reply.

      This method will always set

      invalid reference
      #keepComponents(boolean)
      to `true` to retrieve the original components.
      Parameters:
      replacer - the ComponentReplacer to apply to the original components
      placeholder - the placeholders to use. See PlaceholderResolver
      Throws:
      IllegalStateException - if the original message didn't use V2 Components