Class Event<T extends net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent>

java.lang.Object
io.github.kaktushose.jdac.dispatching.events.Event<T>
Type Parameters:
T - the type of GenericInteractionCreateEvent this event represents
All Implemented Interfaces:
net.dv8tion.jda.api.entities.ISnowflake, net.dv8tion.jda.api.interactions.Interaction
Direct Known Subclasses:
AutoCompleteEvent, ReplyableEvent

public abstract sealed class Event<T extends net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent> extends Object implements net.dv8tion.jda.api.interactions.Interaction permits ReplyableEvent<T>, AutoCompleteEvent

Abstract base event for all interaction events, like CommandEvent.

This class also holds the GenericInteractionCreateEvent and provides some shortcut methods to directly access its content.

See Also:
  • Constructor Details

    • Event

      public Event()
  • Method Details

    • jdaEvent

      public T jdaEvent()
      Returns the underlying GenericInteractionCreateEvent of this event
      Returns:
      the GenericInteractionCreateEvent
    • runtimeId

      public String runtimeId()
      Returns the id of the Runtime this event is dispatched in.
      Returns:
      the id of the current Runtime
    • closeRuntime

      public void closeRuntime()

      Closes the underlying Runtime. This will ignore any new jda events belonging to this interaction, resulting in the freeing of occupied resources for gc.

      This is only needed if the expiration strategy ExpirationStrategy.Explicit is used.

    • kv

      public KeyValueStore kv()

      Returns the KeyValueStore of this Runtime.

      The KeyValueStore can be accessed during the Middleware execution as well as any interaction execution. Its content will be the same as long as the executions take place in the same Runtime.

      Returns:
      the KeyValueStore
    • interactionInstance

      public <I> @Nullable I interactionInstance(Class<I> interactionClass)
      Returns an instance of a class annotated with Interaction, that is bound to the underlying Runtime.
      Returns:
      the interaction class instance
    • introspection

      public Introspection introspection()

      Gets the Introspection instance of this interaction.

      Same as Introspection.accessScoped()

      Returns:
      the Introspection instance with stage set to Stage.INTERACTION.
    • messageResolver

      public MessageResolver messageResolver()
      Gets the MessageResolver instance
      Returns:
      the MessageResolver instance
    • localize

      public String localize(String key, Entry... placeholders)

      Gets a localization message for the given key using the underlying I18n instance.

      Automatically resolves the Locale using GenericInteractionCreateEvent.getUserLocale(). Use I18n.localize(Locale, String, Entry...) (obtained via

      invalid reference
      #i18n()
      ) if you want to use a different locale.
      Returns:
      the localized message or the key if not found
    • resolve

      public String resolve(String message, Entry... placeholders)

      Resolved the given message with help of the underlying MessageResolver instance, thus performing localization and emoji resolution.

      Automatically resolves the Locale using GenericInteractionCreateEvent.getUserLocale(). Use

      invalid reference
      MessageResolver#resolve(String, Locale, Entry...)
      (obtained via messageResolver()) if you want to use a different locale.
      Returns:
      the resolved message
    • getTypeRaw

      public int getTypeRaw()
      Specified by:
      getTypeRaw in interface net.dv8tion.jda.api.interactions.Interaction
    • getToken

      public String getToken()
      Specified by:
      getToken in interface net.dv8tion.jda.api.interactions.Interaction
    • getGuild

      public @Nullable net.dv8tion.jda.api.entities.Guild getGuild()
      Specified by:
      getGuild in interface net.dv8tion.jda.api.interactions.Interaction
    • getUser

      public net.dv8tion.jda.api.entities.User getUser()
      Specified by:
      getUser in interface net.dv8tion.jda.api.interactions.Interaction
    • getMember

      public @Nullable net.dv8tion.jda.api.entities.Member getMember()
      Specified by:
      getMember in interface net.dv8tion.jda.api.interactions.Interaction
    • isAcknowledged

      public boolean isAcknowledged()
      Specified by:
      isAcknowledged in interface net.dv8tion.jda.api.interactions.Interaction
    • getChannel

      public @Nullable net.dv8tion.jda.api.entities.channel.Channel getChannel()
      Specified by:
      getChannel in interface net.dv8tion.jda.api.interactions.Interaction
    • getChannelIdLong

      public long getChannelIdLong()
      Specified by:
      getChannelIdLong in interface net.dv8tion.jda.api.interactions.Interaction
    • getUserLocale

      public net.dv8tion.jda.api.interactions.DiscordLocale getUserLocale()
      Specified by:
      getUserLocale in interface net.dv8tion.jda.api.interactions.Interaction
    • getEntitlements

      public List<net.dv8tion.jda.api.entities.Entitlement> getEntitlements()
      Specified by:
      getEntitlements in interface net.dv8tion.jda.api.interactions.Interaction
    • getJDA

      public net.dv8tion.jda.api.JDA getJDA()
      Specified by:
      getJDA in interface net.dv8tion.jda.api.interactions.Interaction
    • getIdLong

      public long getIdLong()
      Specified by:
      getIdLong in interface net.dv8tion.jda.api.entities.ISnowflake
    • getIntegrationOwners

      public net.dv8tion.jda.api.interactions.IntegrationOwners getIntegrationOwners()
      Specified by:
      getIntegrationOwners in interface net.dv8tion.jda.api.interactions.Interaction
    • getContext

      public net.dv8tion.jda.api.interactions.InteractionContextType getContext()
      Specified by:
      getContext in interface net.dv8tion.jda.api.interactions.Interaction