Class Event<T extends net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent>
- Type Parameters:
T- the type ofGenericInteractionCreateEventthis event represents
- All Implemented Interfaces:
net.dv8tion.jda.api.entities.ISnowflake, net.dv8tion.jda.api.interactions.Interaction
- Direct Known Subclasses:
AutoCompleteEvent, ReplyableEvent
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCloses the underlyingRuntime.@Nullable net.dv8tion.jda.api.entities.channel.Channellongnet.dv8tion.jda.api.interactions.InteractionContextTypeList<net.dv8tion.jda.api.entities.Entitlement> @Nullable net.dv8tion.jda.api.entities.GuildgetGuild()longnet.dv8tion.jda.api.interactions.IntegrationOwnersnet.dv8tion.jda.api.JDAgetJDA()@Nullable net.dv8tion.jda.api.entities.MembergetToken()intnet.dv8tion.jda.api.entities.UsergetUser()net.dv8tion.jda.api.interactions.DiscordLocale<I> @Nullable IinteractionInstance(Class<I> interactionClass) Returns an instance of a class annotated withInteraction, that is bound to the underlyingRuntime.Gets theIntrospectioninstance of this interaction.booleanjdaEvent()Returns the underlyingGenericInteractionCreateEventof this eventkv()Returns theKeyValueStoreof thisRuntime.Gets a localization message for the given key using the underlyingI18ninstance.Gets theMessageResolverinstanceResolved the given message with help of the underlyingMessageResolverinstance, thus performing localization and emoji resolution.Returns the id of theRuntimethis event is dispatched in.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.dv8tion.jda.api.interactions.Interaction
getChannelId, getChannelType, getGuildChannel, getGuildLocale, getMessageChannel, getType, isFromAttachedGuild, isFromGuildMethods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getTimeCreated
-
Constructor Details
-
Event
public Event()
-
-
Method Details
-
jdaEvent
Returns the underlyingGenericInteractionCreateEventof this event- Returns:
- the
GenericInteractionCreateEvent
-
runtimeId
-
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.Explicitis used. -
kv
Returns the
KeyValueStoreof thisRuntime.The
KeyValueStorecan be accessed during theMiddlewareexecution as well as any interaction execution. Its content will be the same as long as the executions take place in the sameRuntime.- Returns:
- the
KeyValueStore
-
interactionInstance
Returns an instance of a class annotated withInteraction, that is bound to the underlyingRuntime.- Returns:
- the interaction class instance
-
introspection
Gets the
Introspectioninstance of this interaction.Same as
Introspection.accessScoped()- Returns:
- the
Introspectioninstance with stage set toStage.INTERACTION.
-
messageResolver
Gets theMessageResolverinstance- Returns:
- the
MessageResolverinstance
-
localize
Gets a localization message for the given key using the underlying
I18ninstance.Automatically resolves the
LocaleusingGenericInteractionCreateEvent.getUserLocale(). UseI18n.localize(Locale, String, Entry...)(obtained viaIntrospection.get(Property.I18N)) if you want to use a different locale.- Returns:
- the localized message or the key if not found
-
resolve
Resolved the given message with help of the underlying
MessageResolverinstance, thus performing localization and emoji resolution.Automatically resolves the
LocaleusingGenericInteractionCreateEvent.getUserLocale(). UseMessageResolver.resolve(String, Locale, Map)(obtained viamessageResolver()) if you want to use a different locale.- Returns:
- the resolved message
-
getTypeRaw
public int getTypeRaw()- Specified by:
getTypeRawin interfacenet.dv8tion.jda.api.interactions.Interaction
-
getToken
- Specified by:
getTokenin interfacenet.dv8tion.jda.api.interactions.Interaction
-
getGuild
public @Nullable net.dv8tion.jda.api.entities.Guild getGuild()- Specified by:
getGuildin interfacenet.dv8tion.jda.api.interactions.Interaction
-
getUser
public net.dv8tion.jda.api.entities.User getUser()- Specified by:
getUserin interfacenet.dv8tion.jda.api.interactions.Interaction
-
getMember
public @Nullable net.dv8tion.jda.api.entities.Member getMember()- Specified by:
getMemberin interfacenet.dv8tion.jda.api.interactions.Interaction
-
isAcknowledged
public boolean isAcknowledged()- Specified by:
isAcknowledgedin interfacenet.dv8tion.jda.api.interactions.Interaction
-
getChannel
public @Nullable net.dv8tion.jda.api.entities.channel.Channel getChannel()- Specified by:
getChannelin interfacenet.dv8tion.jda.api.interactions.Interaction
-
getChannelIdLong
public long getChannelIdLong()- Specified by:
getChannelIdLongin interfacenet.dv8tion.jda.api.interactions.Interaction
-
getUserLocale
public net.dv8tion.jda.api.interactions.DiscordLocale getUserLocale()- Specified by:
getUserLocalein interfacenet.dv8tion.jda.api.interactions.Interaction
-
getEntitlements
- Specified by:
getEntitlementsin interfacenet.dv8tion.jda.api.interactions.Interaction
-
getJDA
public net.dv8tion.jda.api.JDA getJDA()- Specified by:
getJDAin interfacenet.dv8tion.jda.api.interactions.Interaction
-
getIdLong
public long getIdLong()- Specified by:
getIdLongin interfacenet.dv8tion.jda.api.entities.ISnowflake
-
getIntegrationOwners
public net.dv8tion.jda.api.interactions.IntegrationOwners getIntegrationOwners()- Specified by:
getIntegrationOwnersin interfacenet.dv8tion.jda.api.interactions.Interaction
-
getContext
public net.dv8tion.jda.api.interactions.InteractionContextType getContext()- Specified by:
getContextin interfacenet.dv8tion.jda.api.interactions.Interaction
-