Browse Source

Rename enums to use official API naming

pull/6961/head
Rapptz 4 years ago
parent
commit
eda6680377
  1. 14
      discord/enums.py
  2. 2
      discord/ui/button.py
  3. 2
      discord/ui/view.py
  4. 29
      docs/api.rst

14
discord/enums.py

@ -445,7 +445,7 @@ class InteractionResponseType(Enum):
# channel_message = 3 (deprecated) # channel_message = 3 (deprecated)
channel_message = 4 # (with source) channel_message = 4 # (with source)
deferred_channel_message = 5 # (with source) deferred_channel_message = 5 # (with source)
ack = 6 # for components? deferred_message_update = 6 # for components
class VideoQualityMode(Enum): class VideoQualityMode(Enum):
auto = 1 auto = 1
@ -455,18 +455,18 @@ class VideoQualityMode(Enum):
return self.value return self.value
class ComponentType(Enum): class ComponentType(Enum):
group = 1 action_row = 1
button = 2 button = 2
def __int__(self): def __int__(self):
return self.value return self.value
class ButtonStyle(Enum): class ButtonStyle(Enum):
blurple = 1 primary = 1
grey = 2 secondary = 2
green = 3 success = 3
red = 4 danger = 4
hyperlink = 5 link = 5
def __int__(self): def __int__(self):
return self.value return self.value

2
discord/ui/button.py

@ -222,7 +222,7 @@ def button(
*, *,
custom_id: Optional[str] = None, custom_id: Optional[str] = None,
disabled: bool = False, disabled: bool = False,
style: ButtonStyle = ButtonStyle.grey, style: ButtonStyle = ButtonStyle.secondary,
emoji: Optional[Union[str, PartialEmoji]] = None, emoji: Optional[Union[str, PartialEmoji]] = None,
group: Optional[int] = None, group: Optional[int] = None,
) -> Callable[[ItemCallbackType], ItemCallbackType]: ) -> Callable[[ItemCallbackType], ItemCallbackType]:

2
discord/ui/view.py

@ -51,7 +51,7 @@ if TYPE_CHECKING:
def _walk_all_components(components: List[Component]) -> Iterator[Component]: def _walk_all_components(components: List[Component]) -> Iterator[Component]:
for item in components: for item in components:
if item.type is ComponentType.group: if item.type is ComponentType.action_row:
yield from item.children yield from item.children
else: else:
yield item yield item

29
docs/api.rst

@ -1194,9 +1194,10 @@ of :class:`enum.Enum`.
.. attribute:: deferred_channel_message .. attribute:: deferred_channel_message
Responds to a slash command with a message at a later time. Responds to a slash command with a message at a later time.
.. attribute:: ack .. attribute:: deferred_message_update
Acknowledges the component interaction. Acknowledges the component interaction with a promise that
the message will update later (though there is no need to actually update the message).
.. class:: ComponentType .. class:: ComponentType
@ -1204,9 +1205,9 @@ of :class:`enum.Enum`.
.. versionadded:: 2.0 .. versionadded:: 2.0
.. attribute:: group .. attribute:: action_row
Represents the group component which holds different components. Represents the group component which holds different components in a row.
.. attribute:: button .. attribute:: button
Represents a button component. Represents a button component.
@ -1217,21 +1218,21 @@ of :class:`enum.Enum`.
.. versionadded:: 2.0 .. versionadded:: 2.0
.. attribute:: blurple:: .. attribute:: primary::
Represents a blurple button. Represents a blurple button for the primary action.
.. attribute:: grey:: .. attribute:: secondary::
Represents a grey button. Represents a grey button for the secondary action.
.. attribute:: green:: .. attribute:: success::
Represents a green button. Represents a green button for a successful action.
.. attribute:: red:: .. attribute:: danger::
Represents a red button. Represents a red button for a dangerous action.
.. attribute:: hyperlink:: .. attribute:: link::
Represents a hyperlink button. Represents a link button.
.. class:: VoiceRegion .. class:: VoiceRegion

Loading…
Cancel
Save