Package discord4j.rest.interaction
Class InteractionHandlerSpec
- java.lang.Object
-
- discord4j.rest.interaction.InteractionHandlerSpec
-
@Experimental public final class InteractionHandlerSpec extends Object
An immutable builder for creating anRestInteractionhandler function, capable of handling guild and direct message interactions. Configurable instances can be acquired throughInteractions.createHandler()and are built usingbuild(), yielding aFunctionthat can be used in methods such asInteractions.onGlobalCommand(ApplicationCommandRequest, Function).
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Function<RestInteraction,InteractionHandler>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.InteractionHandlerSpecdirect(Function<DirectInteraction,InteractionHandler> directInteractionHandlerFunction)Set a direct message (DM) interaction handler function.InteractionHandlerSpecguild(Function<GuildInteraction,InteractionHandler> guildInteractionHandlerFunction)Set a guild interaction handler function.
-
-
-
Method Detail
-
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
public Function<RestInteraction,InteractionHandler> 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
-
-