Package dev.sympho.bot_utils.component
Class ModalManager
java.lang.Object
dev.sympho.bot_utils.component.ComponentManager<ModalSubmitInteractionEvent,ModalManager.ModalContext,ModalManager.HandlerFunction,ModalManager.Handler,ModalManager.HandlerEntry>
dev.sympho.bot_utils.component.ModalManager
public class ModalManager
extends ComponentManager<ModalSubmitInteractionEvent,ModalManager.ModalContext,ModalManager.HandlerFunction,ModalManager.Handler,ModalManager.HandlerEntry>
Centralized manager for modal submission handling.
- Since:
- 1.0
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordSpecification for the handling of a modal submission.static final recordSpecification for a handler to be registered.static interfaceA function used to handle a modal submit event.final classThe execution context of a modal being submitted.Nested classes/interfaces inherited from class dev.sympho.bot_utils.component.ComponentManager
ComponentManager.ComponentContext<E extends @NonNull ComponentInteractionEvent> -
Field Summary
Fields inherited from class dev.sympho.bot_utils.component.ComponentManager
logger -
Constructor Summary
ConstructorsConstructorDescriptionModalManager(GatewayDiscordClient client, AccessManager accessManager) Creates a new manager that receives interactions from the given client. -
Method Summary
Modifier and TypeMethodDescriptionprotected Class<ModalSubmitInteractionEvent>Retrieves the interaction event type.protected ModalManager.ModalContextmakeContext(ModalSubmitInteractionEvent event, AccessManager accessManager) Creates the interaction context.static StringCreates a custom ID for a modal with arguments in a format that is compatible with this manager.validateInteraction(ModalManager.ModalContext context, ModalManager.Handler handler) Validates that the interaction is allowed.Methods inherited from class dev.sympho.bot_utils.component.ComponentManager
register, register, registerAll, start, stop, unregister
-
Constructor Details
-
ModalManager
Creates a new manager that receives interactions from the given client.- Parameters:
client- The client to receive interactions from.accessManager- The access manager to use.
-
-
Method Details
-
makeId
Creates a custom ID for a modal with arguments in a format that is compatible with this manager.- Parameters:
id- The modal handler ID.args- The interaction arguments.- Returns:
- The assembled custom ID.
-
getEventType
Description copied from class:ComponentManagerRetrieves the interaction event type.- Specified by:
getEventTypein classComponentManager<ModalSubmitInteractionEvent,ModalManager.ModalContext, ModalManager.HandlerFunction, ModalManager.Handler, ModalManager.HandlerEntry> - Returns:
- The interaction event type.
-
makeContext
protected ModalManager.ModalContext makeContext(ModalSubmitInteractionEvent event, AccessManager accessManager) Description copied from class:ComponentManagerCreates the interaction context.- Specified by:
makeContextin classComponentManager<ModalSubmitInteractionEvent,ModalManager.ModalContext, ModalManager.HandlerFunction, ModalManager.Handler, ModalManager.HandlerEntry> - Parameters:
event- The interaction event.accessManager- The access manager.- Returns:
- The created context.
-
validateInteraction
protected Mono<String> validateInteraction(ModalManager.ModalContext context, ModalManager.Handler handler) Description copied from class:ComponentManagerValidates that the interaction is allowed.- Specified by:
validateInteractionin classComponentManager<ModalSubmitInteractionEvent,ModalManager.ModalContext, ModalManager.HandlerFunction, ModalManager.Handler, ModalManager.HandlerEntry> - Parameters:
context- The interaction context.handler- The invoked handler.- Returns:
- A mono that completes empty if the interaction is allowed, otherwise issuing an error message to be sent to the user.
-