mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-06 20:07:17 +00:00
Button labels can be None
This commit is contained in:
parent
1bf782fcb5
commit
6cc3e572ba
@ -106,8 +106,8 @@ class Button(Component):
|
|||||||
The URL this button sends you to.
|
The URL this button sends you to.
|
||||||
disabled: :class:`bool`
|
disabled: :class:`bool`
|
||||||
Whether the button is disabled or not.
|
Whether the button is disabled or not.
|
||||||
label: :class:`str`
|
label: Optional[:class:`str`]
|
||||||
The label of the button.
|
The label of the button, if any.
|
||||||
emoji: Optional[:class:`PartialEmoji`]
|
emoji: Optional[:class:`PartialEmoji`]
|
||||||
The emoji of the button, if available.
|
The emoji of the button, if available.
|
||||||
"""
|
"""
|
||||||
@ -127,7 +127,7 @@ class Button(Component):
|
|||||||
self.custom_id: Optional[str] = data.get('custom_id')
|
self.custom_id: Optional[str] = data.get('custom_id')
|
||||||
self.url: Optional[str] = data.get('url')
|
self.url: Optional[str] = data.get('url')
|
||||||
self.disabled: bool = data.get('disabled', False)
|
self.disabled: bool = data.get('disabled', False)
|
||||||
self.label: str = data['label']
|
self.label: Optional[str] = data.get('label')
|
||||||
self.emoji: Optional[PartialEmoji]
|
self.emoji: Optional[PartialEmoji]
|
||||||
try:
|
try:
|
||||||
self.emoji = PartialEmoji.from_dict(data['emoji'])
|
self.emoji = PartialEmoji.from_dict(data['emoji'])
|
||||||
|
@ -41,12 +41,11 @@ class _ButtonComponentOptional(TypedDict, total=False):
|
|||||||
url: str
|
url: str
|
||||||
disabled: bool
|
disabled: bool
|
||||||
emoji: PartialEmoji
|
emoji: PartialEmoji
|
||||||
|
label: str
|
||||||
|
|
||||||
class ButtonComponent(_ButtonComponentOptional):
|
class ButtonComponent(_ButtonComponentOptional):
|
||||||
type: Literal[2]
|
type: Literal[2]
|
||||||
style: ButtonStyle
|
style: ButtonStyle
|
||||||
label: str
|
|
||||||
|
|
||||||
|
|
||||||
Component = Union[ComponentContainer, ButtonComponent]
|
Component = Union[ComponentContainer, ButtonComponent]
|
||||||
|
@ -82,8 +82,8 @@ class Button(Item[V]):
|
|||||||
The URL this button sends you to.
|
The URL this button sends you to.
|
||||||
disabled: :class:`bool`
|
disabled: :class:`bool`
|
||||||
Whether the button is disabled or not.
|
Whether the button is disabled or not.
|
||||||
label: :class:`str`
|
label: Optional[:class:`str`]
|
||||||
The label of the button.
|
The label of the button, if any.
|
||||||
emoji: Optional[:class:`PartialEmoji`]
|
emoji: Optional[:class:`PartialEmoji`]
|
||||||
The emoji of the button, if available.
|
The emoji of the button, if available.
|
||||||
"""
|
"""
|
||||||
@ -101,7 +101,7 @@ class Button(Item[V]):
|
|||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
style: ButtonStyle,
|
style: ButtonStyle,
|
||||||
label: str,
|
label: Optional[str] = None,
|
||||||
disabled: bool = False,
|
disabled: bool = False,
|
||||||
custom_id: Optional[str] = None,
|
custom_id: Optional[str] = None,
|
||||||
url: Optional[str] = None,
|
url: Optional[str] = None,
|
||||||
@ -174,13 +174,13 @@ class Button(Item[V]):
|
|||||||
self._underlying.disabled = bool(value)
|
self._underlying.disabled = bool(value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def label(self) -> str:
|
def label(self) -> Optional[str]:
|
||||||
""":class:`str`: The label of the button."""
|
"""Optional[:class:`str`]: The label of the button, if available."""
|
||||||
return self._underlying.label
|
return self._underlying.label
|
||||||
|
|
||||||
@label.setter
|
@label.setter
|
||||||
def label(self, value: str):
|
def label(self, value: Optional[str]):
|
||||||
self._underlying.label = str(value)
|
self._underlying.label = str(value) if value is not None else value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def emoji(self) -> Optional[PartialEmoji]:
|
def emoji(self) -> Optional[PartialEmoji]:
|
||||||
@ -221,8 +221,8 @@ class Button(Item[V]):
|
|||||||
|
|
||||||
|
|
||||||
def button(
|
def button(
|
||||||
label: str,
|
|
||||||
*,
|
*,
|
||||||
|
label: Optional[str] = None,
|
||||||
custom_id: Optional[str] = None,
|
custom_id: Optional[str] = None,
|
||||||
disabled: bool = False,
|
disabled: bool = False,
|
||||||
style: ButtonStyle = ButtonStyle.secondary,
|
style: ButtonStyle = ButtonStyle.secondary,
|
||||||
@ -245,8 +245,8 @@ def button(
|
|||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
------------
|
------------
|
||||||
label: :class:`str`
|
label: Optional[:class:`str`]
|
||||||
The label of the button.
|
The label of the button, if any.
|
||||||
custom_id: Optional[:class:`str`]
|
custom_id: Optional[:class:`str`]
|
||||||
The ID of the button that gets received during an interaction.
|
The ID of the button that gets received during an interaction.
|
||||||
It is recommended not to set this parameter to prevent conflicts.
|
It is recommended not to set this parameter to prevent conflicts.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user