Skip to content

Commit

Permalink
Update Activity.buttons documentation (#1394)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorukyum authored Jun 20, 2022
1 parent 99b29e7 commit 769af80
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions discord/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
buttons: list[dict]
label: str (max: 32)
url: str (max: 512)
NOTE: Bots cannot access a user's activity button URLs. When received through the
gateway, the type of the buttons field will be list[str].
There are also activity flags which are mostly uninteresting for the library atm.
Expand Down Expand Up @@ -186,13 +188,18 @@ class Activity(BaseActivity):
- ``id``: A string representing the party ID.
- ``size``: A list of up to two integer elements denoting (current_size, maximum_size).
buttons: List[:class:`dict`]
An list of dictionaries representing custom buttons shown in a rich presence.
buttons: Union[List[:class:`dict`], List[:class:`str`]]
A list of dictionaries representing custom buttons shown in a rich presence.
Each dictionary contains the following keys:
- ``label``: A string representing the text shown on the button.
- ``url``: A string representing the URL opened upon clicking the button.
.. note::
Bots cannot access a user's activity button URLs. Therefore the type of this attribute
will be List[:class:`str`] when received through the gateway.
.. versionadded:: 2.0
emoji: Optional[:class:`PartialEmoji`]
Expand Down Expand Up @@ -230,7 +237,7 @@ def __init__(self, **kwargs):
self.flags: int = kwargs.pop("flags", 0)
self.sync_id: Optional[str] = kwargs.pop("sync_id", None)
self.session_id: Optional[str] = kwargs.pop("session_id", None)
self.buttons: List[ActivityButton] = kwargs.pop("buttons", [])
self.buttons: List[str] = kwargs.pop("buttons", [])

activity_type = kwargs.pop("type", -1)
self.type: ActivityType = (
Expand Down
2 changes: 1 addition & 1 deletion discord/types/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ class Activity(_BaseActivity, total=False):
secrets: ActivitySecrets
session_id: Optional[str]
instance: bool
buttons: List[ActivityButton]
buttons: List[str]

0 comments on commit 769af80

Please sign in to comment.