Package dev.sympho.bot_utils.component
Class ButtonManager
java.lang.Object
dev.sympho.bot_utils.component.ComponentManager<ButtonInteractionEvent,ButtonEventContext,ButtonManager.HandlerFunction,ButtonManager.Handler>
dev.sympho.bot_utils.component.ButtonManager
@Enclosing
public class ButtonManager
extends ComponentManager<ButtonInteractionEvent,ButtonEventContext,ButtonManager.HandlerFunction,ButtonManager.Handler>
Centralized manager for button interaction handling.
- Since:
- 1.0
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSpecification for the handling of a button.static interfaceA function used to handle a button press event. -
Field Summary
Fields inherited from class dev.sympho.bot_utils.component.ComponentManager
logger -
Constructor Summary
ConstructorsConstructorDescriptionButtonManager(GatewayDiscordClient client, AccessManager accessManager) Creates a new manager that receives interactions from the given client. -
Method Summary
Modifier and TypeMethodDescriptionprotected Class<ButtonInteractionEvent>Retrieves the interaction event type.protected ButtonEventContextmakeContext(ButtonInteractionEvent event, AccessManager accessManager) Creates the interaction context.static StringCreates a custom ID for a button with arguments in a format that is compatible with this manager.protected Mono<?>runHandler(ButtonManager.Handler handler, ButtonEventContext context, String args) Executes the selected handler.Methods inherited from class dev.sympho.bot_utils.component.ComponentManager
register, registerAll, reportFailure, sourceField, start, stop, unregister
-
Constructor Details
-
ButtonManager
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 button with arguments in a format that is compatible with this manager.- Parameters:
id- The button 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<ButtonInteractionEvent,ButtonEventContext, ButtonManager.HandlerFunction, ButtonManager.Handler> - Returns:
- The interaction event type.
-
makeContext
Description copied from class:ComponentManagerCreates the interaction context.- Specified by:
makeContextin classComponentManager<ButtonInteractionEvent,ButtonEventContext, ButtonManager.HandlerFunction, ButtonManager.Handler> - Parameters:
event- The interaction event.accessManager- The access manager.- Returns:
- The created context.
-
runHandler
protected Mono<?> runHandler(ButtonManager.Handler handler, ButtonEventContext context, String args) Description copied from class:ComponentManagerExecutes the selected handler.- Overrides:
runHandlerin classComponentManager<ButtonInteractionEvent,ButtonEventContext, ButtonManager.HandlerFunction, ButtonManager.Handler> - Parameters:
handler- The handler to execute.context- The execution context.args- The execution arguments.- Returns:
- A mono that completes when handling is complete. It may result in an
AccessExceptionto indicate that the user does not have sufficient permissions.
-