From 3e7d9462961ba2d1291cb68b9d5618c46c568451 Mon Sep 17 00:00:00 2001 From: megumin Date: Thu, 30 Nov 2023 19:32:48 +0000 Subject: [PATCH] fix(SpotifyControls): Requests double-sending when using Spotify Connect (#2023) --- src/plugins/spotifyControls/index.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/spotifyControls/index.tsx b/src/plugins/spotifyControls/index.tsx index 829f7850a..cfb352efe 100644 --- a/src/plugins/spotifyControls/index.tsx +++ b/src/plugins/spotifyControls/index.tsx @@ -55,13 +55,19 @@ export default definePlugin({ replace: "return [$self.renderPlayer(),$1]" } }, - // Adds POST and a Marker to the SpotifyAPI (so we can easily find it) { find: ".PLAYER_DEVICES", - replacement: { + replacement: [{ + // Adds POST and a Marker to the SpotifyAPI (so we can easily find it) match: /get:(\i)\.bind\(null,(\i\.\i)\.get\)/, replace: "post:$1.bind(null,$2.post),$&" - } + }, + { + // Spotify Connect API returns status 202 instead of 204 when skipping tracks. + // Discord rejects 202 which causes the request to send twice. This patch prevents this. + match: /202===\i\.status/, + replace: "false", + }] }, // Discord doesn't give you the repeat kind, only a boolean {