This PR adds persistent interaction routing allowing for easy persistence and handling of interactions such as button clicks.
It is based on Laravel routing and allows for passing parameters such as {id} and making them optional using a ? like {id?}. All parameters should be passed using : instead of /.
All routes are prefixed with the command name behind the scenes to remain unique.
It is hopefully pretty straight forward to use, see the following example:
/**
* Handle the command.
*/
public function handle($message, $args)
{
return $this
->message()
->title('Hello')
->content('Hello world!')
->button('👋', route: 'wave')
->button('Test', route: 'wave:12345')
->send($message);
}
/**
* The command interaction routes.
*/
public function interactions(): array
{
return [
'wave' => fn (Interaction $interaction) => $this->message('👋')->reply($interaction, true),
'wave:{id?}' => fn (Interaction $interaction, string $id = 'default') => $this->message("Hello from {$id}")->reply($interaction, true),
];
}
This PR adds persistent interaction routing allowing for easy persistence and handling of interactions such as button clicks.
It is based on Laravel routing and allows for passing parameters such as
{id}
and making them optional using a?
like{id?}
. All parameters should be passed using:
instead of/
.All routes are prefixed with the command name behind the scenes to remain unique.
It is hopefully pretty straight forward to use, see the following example: