java.lang.Object
de.chojo.jdautil.interactions.dispatching.InteractionHubBuilder<T,M,U>
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the command hub.Clean all guild commands by redeploying commands to all guilds.cleanGuildCommands(boolean cleanGuildCommands) Clean all guild commands by redeploying commands to all guilds.testMode()Setting the hub to test mode.testMode(boolean testMode) Setting the hub to test mode.withCommandAliases(Function<InteractionMeta, Map<Long, String>> aliasMapper) Defines guild specific names for slash commands.withCommandErrorHandler(BiConsumer<InteractionContext, Throwable> commandErrorHandler) Adds a command error handler to the hub, which handles uncatched exceptions.final InteractionHubBuilder<T, M, U> withCommands(SlashProvider<T>... commands) Register slash interactionsfinal InteractionHubBuilder<T, M, U> withCommands(T... commands) Register slash interactionsAdds a conversation system to the command hubwithEntitlementProvider(BiFunction<User, Guild, List<SKU>> entitlementProvider) withGuildCommandMapper(Function<InteractionMeta, List<Long>> commandMapper) withLocalizer(ILocalizer localizer) Adds a localizer to the hub.withMenuService(Consumer<MenuServiceModifier> builder) final InteractionHubBuilder<T, M, U> withMessages(MessageProvider<M>... messages) Register message interactionsfinal InteractionHubBuilder<T, M, U> withMessages(M... messages) Register message interactionswithModalService(Consumer<ModalServiceModifier> builder) withPagination(Consumer<PageServiceModifier> builder) withPostCommandHook(Consumer<InteractionResult> postCommandHook) Adds a post command hook to the hub, which gets executed after every successful or unsuccessful command execution.withPremiumErrorMessage(String errorMessage) withSKUConfiguration(SKUConfiguration skuConfiguration) final InteractionHubBuilder<T, M, U> withUsers(UserProvider<U>... users) Register user interactionsfinal InteractionHubBuilder<T, M, U> Register user interactions
-
Method Details
-
withGuildCommandMapper
public InteractionHubBuilder<T,M, withGuildCommandMapperU> (Function<InteractionMeta, List<Long>> commandMapper) -
withCommandAliases
public InteractionHubBuilder<T,M, withCommandAliasesU> (Function<InteractionMeta, Map<Long, String>> aliasMapper) Defines guild specific names for slash commands.A private command is registered under its alias instead of its name on that guild. The guilds of a private command are still defined by the
guild command mapper. A global command stays global and is additionally registered as a guild command under its alias.The mapper is called for every slash command whenever guild commands are built, which happens on startup and on every
refresh.- Parameters:
aliasMapper- maps a command to the alias it has on each guild, keyed by guild id- Returns:
- builder instance
-
cleanGuildCommands
Clean all guild commands by redeploying commands to all guilds.- Returns:
- builder instance
-
cleanGuildCommands
Clean all guild commands by redeploying commands to all guilds.- Parameters:
cleanGuildCommands- true to clean- Returns:
- builder instance
-
testMode
Setting the hub to test mode. This will cause all global interactions to be deployed on a guild level instead and removing global interactions.- Parameters:
testMode- true to activate- Returns:
- builder instance
-
testMode
Setting the hub to test mode. This will cause all global interactions to be deployed on a guild level instead and removing global interactions.- Returns:
- builder instance
-
withLocalizer
Adds a localizer to the hub. This will allow to useLocalizationContext.- Parameters:
localizer- localizer instance- Returns:
- builder instance
-
withCommands
Register slash interactions- Parameters:
commands- commands to register- Returns:
- builder instance
-
withCommands
Register slash interactions- Parameters:
commands- commands to register- Returns:
- builder instance
-
withMessages
Register message interactions- Parameters:
messages- commands to register- Returns:
- builder instance
-
withMessages
Register message interactions- Parameters:
messages- commands to register- Returns:
- builder instance
-
withUsers
Register user interactions- Parameters:
users- commands to register- Returns:
- builder instance
-
withUsers
Register user interactions- Parameters:
users- commands to register- Returns:
- builder instance
-
withConversationSystem
Adds a conversation system to the command hub- Returns:
- builder instance
-
withCommandErrorHandler
public InteractionHubBuilder<T,M, withCommandErrorHandlerU> (BiConsumer<InteractionContext, Throwable> commandErrorHandler) Adds a command error handler to the hub, which handles uncatched exceptions. Used for loggin.- Parameters:
commandErrorHandler- handler for errors- Returns:
- builder instance
-
withPostCommandHook
public InteractionHubBuilder<T,M, withPostCommandHookU> (Consumer<InteractionResult> postCommandHook) Adds a post command hook to the hub, which gets executed after every successful or unsuccessful command execution.- Parameters:
postCommandHook- handler- Returns:
- builder instance
-
withPagination
-
withDefaultPagination
-
withMenuService
-
withDefaultMenuService
-
withModalService
-
withDefaultModalService
-
withPremiumErrorMessage
-
withEntitlementProvider
public InteractionHubBuilder<T,M, withEntitlementProviderU> (BiFunction<User, Guild, List<SKU>> entitlementProvider) -
build
Build the command hub.This will register the command hub as a listener.
This will also deploy the commands. The deployment runs on a separate thread, see
InteractionHub.deployment().- Returns:
- command hub instance
-