From 57306c6200d84c520492c365b8dfbb5830989bb1 Mon Sep 17 00:00:00 2001 From: dolfies Date: Mon, 12 Feb 2024 21:55:34 -0500 Subject: [PATCH] Fix duplicate custom status checking --- discord/client.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/discord/client.py b/discord/client.py index 4bf9759e658a..d0a4742b8f66 100644 --- a/discord/client.py +++ b/discord/client.py @@ -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: @@ -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