Browse Source

chore(breaking): Rename SeparatorSize to SeparatorSpacing

pull/10166/head
DA-344 2 months ago
parent
commit
42bd21a700
  1. 6
      discord/components.py
  2. 4
      discord/enums.py
  3. 12
      discord/ui/separator.py
  4. 4
      discord/ui/view.py

6
discord/components.py

@ -42,7 +42,7 @@ from .enums import (
TextStyle, TextStyle,
ChannelType, ChannelType,
SelectDefaultValueType, SelectDefaultValueType,
SeparatorSize, SeparatorSpacing,
MediaItemLoadingState, MediaItemLoadingState,
) )
from .flags import AttachmentFlags from .flags import AttachmentFlags
@ -1158,7 +1158,7 @@ class SeparatorComponent(Component):
Attributes Attributes
---------- ----------
spacing: :class:`SeparatorSize` spacing: :class:`SeparatorSpacing`
The spacing size of the separator. The spacing size of the separator.
visible: :class:`bool` visible: :class:`bool`
Whether this separator is visible and shows a divider. Whether this separator is visible and shows a divider.
@ -1178,7 +1178,7 @@ class SeparatorComponent(Component):
self, self,
data: SeparatorComponentPayload, data: SeparatorComponentPayload,
) -> None: ) -> None:
self.spacing: SeparatorSize = try_enum(SeparatorSize, data.get('spacing', 1)) self.spacing: SeparatorSpacing = try_enum(SeparatorSpacing, data.get('spacing', 1))
self.visible: bool = data.get('divider', True) self.visible: bool = data.get('divider', True)
self.id: Optional[int] = data.get('id') self.id: Optional[int] = data.get('id')

4
discord/enums.py

@ -77,7 +77,7 @@ __all__ = (
'VoiceChannelEffectAnimationType', 'VoiceChannelEffectAnimationType',
'SubscriptionStatus', 'SubscriptionStatus',
'MessageReferenceType', 'MessageReferenceType',
'SeparatorSize', 'SeparatorSpacing',
'MediaItemLoadingState', 'MediaItemLoadingState',
) )
@ -872,7 +872,7 @@ class SubscriptionStatus(Enum):
inactive = 2 inactive = 2
class SeparatorSize(Enum): class SeparatorSpacing(Enum):
small = 1 small = 1
large = 2 large = 2

12
discord/ui/separator.py

@ -27,7 +27,7 @@ from typing import TYPE_CHECKING, Literal, Optional, TypeVar
from .item import Item from .item import Item
from ..components import SeparatorComponent from ..components import SeparatorComponent
from ..enums import SeparatorSize, ComponentType from ..enums import SeparatorSpacing, ComponentType
if TYPE_CHECKING: if TYPE_CHECKING:
from typing_extensions import Self from typing_extensions import Self
@ -51,7 +51,7 @@ class Separator(Item[V]):
visible: :class:`bool` visible: :class:`bool`
Whether this separator is visible. On the client side this Whether this separator is visible. On the client side this
is whether a divider line should be shown or not. is whether a divider line should be shown or not.
spacing: :class:`.SeparatorSize` spacing: :class:`.SeparatorSpacing`
The spacing of this separator. The spacing of this separator.
row: Optional[:class:`int`] row: Optional[:class:`int`]
The relative row this separator belongs to. By default The relative row this separator belongs to. By default
@ -68,7 +68,7 @@ class Separator(Item[V]):
self, self,
*, *,
visible: bool = True, visible: bool = True,
spacing: SeparatorSize = SeparatorSize.small, spacing: SeparatorSpacing = SeparatorSpacing.small,
row: Optional[int] = None, row: Optional[int] = None,
id: Optional[int] = None, id: Optional[int] = None,
) -> None: ) -> None:
@ -99,12 +99,12 @@ class Separator(Item[V]):
self._underlying.visible = value self._underlying.visible = value
@property @property
def spacing(self) -> SeparatorSize: def spacing(self) -> SeparatorSpacing:
""":class:`.SeparatorSize`: The spacing of this separator.""" """:class:`.SeparatorSpacing`: The spacing of this separator."""
return self._underlying.spacing return self._underlying.spacing
@spacing.setter @spacing.setter
def spacing(self, value: SeparatorSize) -> None: def spacing(self, value: SeparatorSpacing) -> None:
self._underlying.spacing = value self._underlying.spacing = value
@property @property

4
discord/ui/view.py

@ -70,7 +70,7 @@ from ..components import (
SelectOption, SelectOption,
) )
from ..utils import get as _utils_get, _get_as_snowflake from ..utils import get as _utils_get, _get_as_snowflake
from ..enums import SeparatorSize, TextStyle, try_enum, ButtonStyle from ..enums import SeparatorSpacing, TextStyle, try_enum, ButtonStyle
from ..emoji import PartialEmoji from ..emoji import PartialEmoji
# fmt: off # fmt: off
@ -260,7 +260,7 @@ def _component_data_to_item(data: ComponentPayload) -> Item:
return Separator( return Separator(
visible=data.get('divider', True), visible=data.get('divider', True),
spacing=try_enum(SeparatorSize, data.get('spacing', 1)), spacing=try_enum(SeparatorSpacing, data.get('spacing', 1)),
id=data.get('id'), id=data.get('id'),
) )
elif data['type'] == 17: elif data['type'] == 17:

Loading…
Cancel
Save