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

4
discord/enums.py

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

12
discord/ui/separator.py

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

4
discord/ui/view.py

@ -70,7 +70,7 @@ from ..components import (
SelectOption,
)
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
# fmt: off
@ -260,7 +260,7 @@ def _component_data_to_item(data: ComponentPayload) -> Item:
return Separator(
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'),
)
elif data['type'] == 17:

Loading…
Cancel
Save