Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for custom status #2206

Merged
merged 8 commits into from Aug 18, 2023
Merged
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
11 changes: 8 additions & 3 deletions discord/activity.py
Expand Up @@ -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`]
Expand Down Expand Up @@ -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)
Expand All @@ -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 = (
Expand All @@ -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),
Expand Down Expand Up @@ -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")
Expand All @@ -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
Lulalaby marked this conversation as resolved.
Show resolved Hide resolved

Expand Down