From e67d00502d91c15914c640e1aae40e15544cdfa1 Mon Sep 17 00:00:00 2001 From: z03h <7235242+z03h@users.noreply.github.com> Date: Tue, 12 Sep 2023 10:03:29 -0700 Subject: [PATCH] Fix View.from_message not creating other Selects --- discord/ui/select.py | 1 + discord/ui/view.py | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/discord/ui/select.py b/discord/ui/select.py index 222596075..e54180cac 100644 --- a/discord/ui/select.py +++ b/discord/ui/select.py @@ -235,6 +235,7 @@ class BaseSelect(Item[V]): def from_component(cls, component: SelectMenu) -> Self: return cls( **{k: getattr(component, k) for k in cls.__item_repr_attributes__}, + custom_id=component.custom_id, row=None, ) diff --git a/discord/ui/view.py b/discord/ui/view.py index 883b87c84..32acbadda 100644 --- a/discord/ui/view.py +++ b/discord/ui/view.py @@ -34,6 +34,7 @@ import time import os from .item import Item, ItemCallbackType from .dynamic import DynamicItem +from ..enums import ComponentType from ..components import ( Component, ActionRow as ActionRowComponent, @@ -78,9 +79,26 @@ def _component_to_item(component: Component) -> Item: return Button.from_component(component) if isinstance(component, SelectComponent): - from .select import Select + if component.type is ComponentType.select: + from .select import Select - return Select.from_component(component) + return Select.from_component(component) + elif component.type is ComponentType.user_select: + from .select import UserSelect + + return UserSelect.from_component(component) + elif component.type is ComponentType.mentionable_select: + from .select import MentionableSelect + + return MentionableSelect.from_component(component) + elif component.type is ComponentType.channel_select: + from .select import ChannelSelect + + return ChannelSelect().from_component(component) + elif component.type is ComponentType.role_select: + from .select import RoleSelect + + return RoleSelect.from_component(component) return Item.from_component(component)