Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatten the component builders #1533

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions changes/1533.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Refactors to the component builder interfaces which make them flatter:

* Removed `add_to_container` from `ButtonBuilder`, `LinkButtonBuilder`, `InteractiveButtonBuilder`, `SelectMenuBuilder`, `ChannelSelectMenuBuilder`, and `TextInputBuilder`; these classes are no-longer generic and no-longer take `container` in their inits.
* Replaced `TextSelectMenuBuilder.add_to_container` with the `TextSelectMenuBuilder.parent` property.
This new property doesn't "finalise" the addition but rather just returns the parent object, or raises if the select menu is an orphan. This change also involves replacing the `container` parameter in `TextSelectMenuBuilder.__init__` with an optional `parent` parameter.
* Removed `SelectOptionBuilder.add_to_menu`; this class isn't generic anymore.
* `TextSelectMenuBuilder.add_option` now takes all the option's configuration as parameters and returns `Self`.
* Split `MessageActionRowBuilder.add_button` into `.add_interactive_button` and `.add_link_button`.
These both now take all the button's configuration as parameters and return `Self`.
* `MessageActionRowBuilder.add_select_menu` now takes all the menu's configuration as parameters and returns `Self`.
The new `.add_channel_menu` and `.add_text_menu` methods should be used for adding text and channel menus. Where `.add_channel_menu` returns `Self` and `.add_text_menu` returns a text menu builder with a `parent` property for getting back to the action row builder.
* `ModalActionRowBuilder.add_text_input` now takes all the text input's configuration as parameters and returns `Self`.
* `min_length` and `max_length` can no-longer be `hikari.undefined.UNDEFINED` for the text input builder, and default to `0` and `4000` respectively. This change effects both the types accepted by `ModalActionRowBuilder.__init__` and the return types of the relevant properties.
* Removed the `emoji_id` and `emoji_name` parameters from `LinkButtonBuilder.__init__`, and `InteractiveButtonBuilder.__init__`.
* Removed the `style` and `custom_id` parameters from `LinkButtonBuilder.__init__`.
* Removed the `url` parameter from `InteractiveButtonBuilder.__init__`.
1 change: 1 addition & 0 deletions changes/1533.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`emoji=` can now be passed to `LinkButtonBuilder.__init__` and `InteractiveButtonBuilder.__init__` alone without causing serialization issues (and Pyright will now let you pass it).
1 change: 1 addition & 0 deletions changes/1533.deprecation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Renamed `TextInputBuilder.required` property to `TextInputBuilder.is_required`.
4 changes: 4 additions & 0 deletions changes/1533.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Refactors to the component builder interfaces which make them flatter:

* `hikari.undefined.UNDEFINED` can now be passed to `TextInputBuilder.set_placeholder` and `TextInputBuilder.set_value`.
* The standard implementation of a select option builder is now exposed at `hikari.impl.special_endpoints.SelectOptionBuilder`.
Loading