Package discord4j.rest.interaction
Class InteractionHandlerSpec
java.lang.Object
discord4j.rest.interaction.InteractionHandlerSpec
An immutable builder for creating an
RestInteraction handler function, capable of handling guild and direct
message interactions. Configurable instances can be acquired through Interactions.createHandler() and are
built using build(), yielding a Function that can be used in methods such as
Interactions.onGlobalCommand(ApplicationCommandRequest, Function).-
Method Summary
Modifier and TypeMethodDescriptionbuild()Produce an interaction handler function to be used in a method such asInteractions.onGlobalCommand(ApplicationCommandRequest, Function)and will route to the appropriate guild or direct message interaction handler.direct(Function<DirectInteraction, InteractionHandler> directInteractionHandlerFunction) Set a direct message (DM) interaction handler function.guild(Function<GuildInteraction, InteractionHandler> guildInteractionHandlerFunction) Set a guild interaction handler function.
-
Method Details
-
guild
public InteractionHandlerSpec guild(Function<GuildInteraction, InteractionHandler> guildInteractionHandlerFunction) Set a guild interaction handler function. Any previous guild interaction handling function set will be overridden.- Parameters:
guildInteractionHandlerFunction- a function to derive anInteractionHandlerfrom aGuildInteraction- Returns:
- this spec for chaining, call
build()to produce a complete handler
-
direct
public InteractionHandlerSpec direct(Function<DirectInteraction, InteractionHandler> directInteractionHandlerFunction) Set a direct message (DM) interaction handler function. Any previous DM interaction handling function set will be overridden.- Parameters:
directInteractionHandlerFunction- a function to derive anInteractionHandlerfrom aDirectInteraction- Returns:
- this spec for chaining, call
build()to produce a complete handler
-
build
Produce an interaction handler function to be used in a method such asInteractions.onGlobalCommand(ApplicationCommandRequest, Function)and will route to the appropriate guild or direct message interaction handler.- Returns:
- a mapper to convert an
RestInteractioninto anInteractionHandler
-