Skip to content

Commit

Permalink
Fix duplicate custom status checking
Browse files Browse the repository at this point in the history
  • Loading branch information
dolfies committed Feb 13, 2024
1 parent 0d2c90e commit 57306c6
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,7 @@ async def change_presence(
TypeError
The ``activity`` parameter is not the proper type.
Both ``activity`` and ``activities`` were passed.
ValueError
More than one custom activity was passed.
"""
if activity is not MISSING and activities is not MISSING:
Expand All @@ -1745,17 +1746,17 @@ async def change_presence(
else:
since = int(idle_since.timestamp() * 1000) if idle_since else 0

custom_activity = None
if not skip_activities:
for activity in activities:
if getattr(activity, 'type', None) is ActivityType.custom:
if custom_activity is not None:
raise ValueError('More than one custom activity was passed')
custom_activity = activity

await self.ws.change_presence(status=status, activities=activities, afk=afk, since=since)

if edit_settings and self.settings:
custom_activity = None
if not skip_activities:
for activity in activities:
if getattr(activity, 'type', None) is ActivityType.custom:
if custom_activity is not None:
raise TypeError('More than one custom activity was passed')
custom_activity = activity

payload: Dict[str, Any] = {}
if not skip_status and status != self.settings.status:
payload['status'] = status
Expand Down

0 comments on commit 57306c6

Please sign in to comment.