From 769af80a578ef9f630430fa7e0a57a212a63a2c5 Mon Sep 17 00:00:00 2001 From: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Date: Mon, 20 Jun 2022 23:37:21 +0300 Subject: [PATCH] Update Activity.buttons documentation (#1394) --- discord/activity.py | 13 ++++++++++--- discord/types/activity.py | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/discord/activity.py b/discord/activity.py index 8202d468ae..2aa6a1739b 100644 --- a/discord/activity.py +++ b/discord/activity.py @@ -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. @@ -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`] @@ -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 = ( diff --git a/discord/types/activity.py b/discord/types/activity.py index f277643bc8..f7805985ad 100644 --- a/discord/types/activity.py +++ b/discord/types/activity.py @@ -112,4 +112,4 @@ class Activity(_BaseActivity, total=False): secrets: ActivitySecrets session_id: Optional[str] instance: bool - buttons: List[ActivityButton] + buttons: List[str]