NAME

Discord::Client::UI - Hashref helpers for buttons and modal inputs

SYNOPSIS

use Discord::Client::UI qw(row button text_input modal);

# Build message controls without I/O.
my $controls = [row(button('open_form', label => 'Open form'))];

# Build a modal for $interaction->modal($form).
my $form = modal(
    'feedback_form', title => 'Feedback',
    fields => [text_input('note', label => 'Your note', style => 'paragraph')],
);

DESCRIPTION

Optional functions that return Discord hashrefs without I/O. Invalid supported arguments throw. Use native JSON for additional component types and fields. Register handlers with "component" in Discord::Client; read submitted text with "field" in Discord::Client::Interaction.

FUNCTIONS

button

button(custom_id, label => ..., style => ...) returns an interactive button hashref. Styles are primary (default), secondary, success and danger. A label is required. disabled becomes a JSON boolean; additional fields such as emoji are preserved. Use native JSON for emoji-only, link or premium buttons.

row

row(components...) returns a message Action Row with one to five buttons or one native select menu. These rows work with content and do not set the Components V2 flag.

text_input

text_input(custom_id, label => ..., style => ...) returns a Label containing a Text Input. Styles are short (default) and paragraph. description belongs to the Label; required, min_length, max_length, placeholder and value belong to the input. required becomes a JSON boolean. Omitting it uses Discord's default.

modal(custom_id, title => ..., fields => [...]) returns a modal hashref with one to five Labels and unique field IDs. Send it explicitly with $interaction->modal($form).

LICENSE

Apache License 2.0.