GitHub

HandlerService

API reference for HandlerService.

What an adapter calls with an interaction (public, for a consumer that routes clicks itself). The contract is to answer inside the platform's 3 seconds, with no error channel. refused is called when a click's or a command's reply was not carried out (no modal opened, a private answer without ephemeral, a refusal by the platform, or a reply past the deadline).

Functions

__init__

__init__(*, click, submit, command, refused) -> None
ParameterTypeDescription
clickCallable[[ButtonClicked | SelectChanged], Effect[ClickReply]]
submitCallable[[ModalSubmitted], Effect[SubmitReply]]
commandCallable[[CommandInvoked], Effect[CommandReply]]
refusedCallable[[ButtonClicked | SelectChanged | CommandInvoked, ChatError], Effect[None]]
def __init__(
    self,
    *,
    click: Callable[[ButtonClicked | SelectChanged], Effect[ClickReply]],
    submit: Callable[[ModalSubmitted], Effect[SubmitReply]],
    command: Callable[[CommandInvoked], Effect[CommandReply]],
    refused: Callable[
        [ButtonClicked | SelectChanged | CommandInvoked, ChatError], Effect[None]
    ],
) -> None:
    self._click = click
    self._submit = submit
    self._command = command
    self._refused = refused

click

click(event) -> Effect[ClickReply]

The reply to a button click or a select change.

ParameterTypeDescription
eventButtonClicked | SelectChanged

Returns Effect[ClickReply]

def click(self, event: ButtonClicked | SelectChanged) -> Effect[ClickReply]:
    """The reply to a button click or a select change."""
    return self._click(event)

submit

submit(event) -> Effect[SubmitReply]

The reply to a modal submit.

ParameterTypeDescription
eventModalSubmitted

Returns Effect[SubmitReply]

def submit(self, event: ModalSubmitted) -> Effect[SubmitReply]:
    """The reply to a modal submit."""
    return self._submit(event)

command

command(event) -> Effect[CommandReply]

The reply to a slash command.

ParameterTypeDescription
eventCommandInvoked

Returns Effect[CommandReply]

def command(self, event: CommandInvoked) -> Effect[CommandReply]:
    """The reply to a slash command."""
    return self._command(event)

refused

refused(event, error) -> Effect[None]

Reports that a click's or a command's reply was not carried out.

ParameterTypeDescription
eventButtonClicked | SelectChanged | CommandInvoked
errorChatError

Returns Effect[None]

def refused(
    self, event: ButtonClicked | SelectChanged | CommandInvoked, error: ChatError
) -> Effect[None]:
    """Reports that a click's or a command's reply was not carried out."""
    return self._refused(event, error)