addButtons method
Adds multiple buttons in a single row.
Discord supports up to 5 buttons per action row. If you need more buttons, call this method multiple times to create separate rows.
Example:
builder.addButtons([
MessageButton.primary('yes', label: 'Yes'),
MessageButton.secondary('no', label: 'No'),
MessageButton.danger('cancel', label: 'Cancel'),
]);
Throws an ArgumentError if more than 5 buttons are provided.
See also:
- addButton to add a single button
Implementation
void addButtons(List<Button> buttons) {
if (buttons.length > 5) {
throw ArgumentError.value(
buttons.length,
'buttons',
'A row can contain at most 5 buttons (received ${buttons.length}).',
);
}
final row = ActionRow(components: buttons);
_components.add(row);
}