Skip to content

Commit f07921f

Browse files
committed
Remove ability for usage in change_presence
1 parent 517962b commit f07921f

File tree

2 files changed

+9
-28
lines changed

2 files changed

+9
-28
lines changed

discord/activity.py

+6-25
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ def __repr__(self) -> str:
827827
return f'<CustomActivity name={self.name!r} emoji={self.emoji!r}>'
828828

829829

830-
class HangStatus(BaseActivity):
830+
class HangStatus:
831831
"""A slimmed down version of :class:`Activity` that represents a Discord hang status.
832832
833833
This is typically displayed via **Right now, I'm -** on the official Discord client.
@@ -864,17 +864,17 @@ class HangStatus(BaseActivity):
864864

865865
__slots__ = ('state', 'name', 'emoji')
866866

867-
def __init__(self, state: str, emoji: Optional[Union[PartialEmoji, Dict[str, Any], str]] = None, **extra: Any) -> None:
868-
super().__init__(**extra)
869-
self.state: HangStatusType = try_enum(HangStatusType, state)
867+
def __init__(self, **data: Any) -> None:
868+
self.state: HangStatusType = try_enum(HangStatusType, data['state'])
870869

871870
self.name: str
872871
if self.state == HangStatusType.custom:
873-
self.name = extra['details']
872+
self.name = data['details']
874873
else:
875874
self.name = self.state.value
876875

877876
self.emoji: Optional[PartialEmoji]
877+
emoji = data.get('emoji')
878878
if emoji is None:
879879
self.emoji = emoji
880880
elif isinstance(emoji, dict):
@@ -894,25 +894,6 @@ def type(self) -> ActivityType:
894894
"""
895895
return ActivityType.hang
896896

897-
def to_dict(self) -> Dict[str, Any]:
898-
if self.state == HangStatusType.custom:
899-
ret = {
900-
'type': ActivityType.hang.value,
901-
'name': 'Hang Status',
902-
'state': self.state.value,
903-
'details': self.name,
904-
}
905-
else:
906-
ret = {
907-
'type': ActivityType.hang.value,
908-
'name': 'Hang Status',
909-
'state': self.state.value,
910-
}
911-
912-
if self.emoji:
913-
ret['emoji'] = self.emoji.to_dict()
914-
return ret
915-
916897
def __str__(self) -> str:
917898
return str(self.name)
918899

@@ -967,7 +948,7 @@ def create_activity(data: Optional[ActivityPayload], state: ConnectionState) ->
967948
elif game_type is ActivityType.listening and 'sync_id' in data and 'session_id' in data:
968949
return Spotify(**data)
969950
elif game_type is ActivityType.hang:
970-
return HangStatus(**data) # type: ignore
951+
return HangStatus(**data)
971952
else:
972953
ret = Activity(**data)
973954

discord/widget.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
from .utils import snowflake_time, _get_as_snowflake, resolve_invite
3030
from .user import BaseUser
31-
from .activity import BaseActivity, Spotify, create_activity
31+
from .activity import BaseActivity, Spotify, HangStatus, create_activity
3232
from .invite import Invite
3333
from .enums import Status, try_enum
3434

@@ -167,7 +167,7 @@ class WidgetMember(BaseUser):
167167
)
168168

169169
if TYPE_CHECKING:
170-
activity: Optional[Union[BaseActivity, Spotify]]
170+
activity: Optional[Union[BaseActivity, Spotify, HangStatus]]
171171

172172
def __init__(
173173
self,
@@ -190,7 +190,7 @@ def __init__(
190190
else:
191191
activity = create_activity(game, state)
192192

193-
self.activity: Optional[Union[BaseActivity, Spotify]] = activity
193+
self.activity: Optional[Union[BaseActivity, Spotify, HangStatus]] = activity
194194

195195
self.connected_channel: Optional[WidgetChannel] = connected_channel
196196

0 commit comments

Comments
 (0)