From a26117691c4aa0330d59d78ae32d5cf765dadc4d Mon Sep 17 00:00:00 2001 From: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Date: Fri, 18 Aug 2023 14:39:31 +0300 Subject: [PATCH] feat: add support for custom status (#2206) --- CHANGELOG.md | 2 ++ discord/activity.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2e3ef75f9..45f8d1e2fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,6 +74,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2138](https://github.com/Pycord-Development/pycord/pull/2138)) - Added `wait_finish` parameter to `VoiceClient.play` for awaiting the end of a play. ([#2194](https://github.com/Pycord-Development/pycord/pull/2194)) +- Added support for custom bot status. + ([#2206](https://github.com/Pycord-Development/pycord/pull/2206)) ### Changed diff --git a/discord/activity.py b/discord/activity.py index a00add5cd8..96b20255a8 100644 --- a/discord/activity.py +++ b/discord/activity.py @@ -160,7 +160,7 @@ class Activity(BaseActivity): type: :class:`ActivityType` The type of activity currently being done. state: Optional[:class:`str`] - The user's current state. For example, "In Game". + The user's current party status or text used for a custom status. details: Optional[:class:`str`] The detail of the user's current activity. timestamps: Dict[:class:`str`, :class:`int`] @@ -229,7 +229,6 @@ def __init__(self, **kwargs): self.assets: ActivityAssets = kwargs.pop("assets", {}) self.party: ActivityParty = kwargs.pop("party", {}) self.application_id: int | None = _get_as_snowflake(kwargs, "application_id") - self.name: str | None = kwargs.pop("name", None) self.url: str | None = kwargs.pop("url", None) self.flags: int = kwargs.pop("flags", 0) self.sync_id: str | None = kwargs.pop("sync_id", None) @@ -242,6 +241,9 @@ def __init__(self, **kwargs): if isinstance(activity_type, ActivityType) else try_enum(ActivityType, activity_type) ) + self.name: str | None = kwargs.pop( + "name", "Custom Status" if self.type == ActivityType.custom else None + ) emoji = kwargs.pop("emoji", None) self.emoji: PartialEmoji | None = ( @@ -252,6 +254,7 @@ def __repr__(self) -> str: attrs = ( ("type", self.type), ("name", self.name), + ("state", self.state), ("url", self.url), ("details", self.details), ("application_id", self.application_id), @@ -760,6 +763,8 @@ class CustomActivity(BaseActivity): The custom activity's name. emoji: Optional[:class:`PartialEmoji`] The emoji to pass to the activity, if any. + state: Optional[:class:`str`] + The text used for the custom activity. """ __slots__ = ("name", "emoji", "state") @@ -769,7 +774,7 @@ def __init__( ): super().__init__(**extra) self.name: str | None = name - self.state: str | None = extra.pop("state", None) + self.state: str | None = extra.pop("state", name) if self.name == "Custom Status": self.name = self.state