From 8cdcfe31c2e1a04de31ea8b2a4524a2e171cf432 Mon Sep 17 00:00:00 2001 From: Lunarmagpie Date: Wed, 8 Feb 2023 20:29:07 -0500 Subject: [PATCH] Add `set_channel_types` function (#99) --- flare/components/base.py | 19 +++++++++++++------ flare/components/select.py | 4 ++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/flare/components/base.py b/flare/components/base.py index f7071e0..bc1985a 100644 --- a/flare/components/base.py +++ b/flare/components/base.py @@ -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 diff --git a/flare/components/select.py b/flare/components/select.py index 1368b24..2d14fcb 100644 --- a/flare/components/select.py +++ b/flare/components/select.py @@ -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(