diff --git a/discord/components.py b/discord/components.py index d2cdd17adc99..2665e89f28f9 100644 --- a/discord/components.py +++ b/discord/components.py @@ -43,6 +43,7 @@ SelectDefaultValues as SelectDefaultValuesPayload, ) from .emoji import Emoji + from .abc import Snowflake ActionRowChildComponentType = Union['Button', 'SelectMenu', 'TextInput'] @@ -570,7 +571,28 @@ def to_dict(self) -> SelectDefaultValuesPayload: 'id': self.id, 'type': self._type.value, } - + + @classmethod + def from_channel(cls, channel: Snowflake, /) -> Self: + return cls( + id=channel.id, + type=SelectDefaultValueType.channel, + ) + + @classmethod + def from_role(cls, role: Snowflake, /) -> Self: + return cls( + id=role.id, + type=SelectDefaultValueType.role, + ) + + @classmethod + def from_user(cls, user: Snowflake, /) -> Self: + return cls( + id=user.id, + type=SelectDefaultValueType.user, + ) + @overload def _component_factory(data: ActionRowChildComponentPayload) -> Optional[ActionRowChildComponentType]: