Skip to content

Commit

Permalink
Add set_channel_types function (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
zunda-arrow authored Feb 9, 2023
1 parent 85bd616 commit 8cdcfe3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
19 changes: 13 additions & 6 deletions flare/components/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,24 @@ async def from_partial(component: hikari.PartialComponent) -> CallbackComponent:
component_inst, TextSelect | RoleSelect | UserSelect | MentionableSelect | ChannelSelect
)

component_inst.set_max_values(component.max_values).set_placeholder(
component.placeholder or hikari.UNDEFINED
).set_disabled(component.is_disabled)
(
component_inst.set_max_values(component.max_values)
.set_min_values(component.min_values)
.set_placeholder(component.placeholder or hikari.UNDEFINED)
.set_disabled(component.is_disabled)
)

if isinstance(component, hikari.components.TextSelectMenuComponent):
if t.TYPE_CHECKING:
assert isinstance(component_inst, TextSelect)

component_inst.set_options(
*((option.label, option.value) for option in component.options)
).set_min_values(component.min_values)
component_inst.set_options(*((option.label, option.value) for option in component.options))

if isinstance(component, hikari.components.ChannelSelectMenuComponent):
if t.TYPE_CHECKING:
assert isinstance(component_inst, ChannelSelect)

component_inst.set_channel_types(*(hikari.ChannelType(c) for c in component.channel_types))

return component_inst

Expand Down
4 changes: 2 additions & 2 deletions flare/components/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ def __post_init__(self):
super().__post_init__()
self.channel_types = self.__channel_types

def set_options(self, *options: tuple[str, str] | str | hikari.SelectMenuOption) -> Self:
self.options = options
def set_channel_types(self, *channel_types: hikari.ChannelType) -> Self:
self.channel_types = channel_types
return self

def build(
Expand Down

0 comments on commit 8cdcfe3

Please sign in to comment.