Skip to content

Commit d52d46f

Browse files
committed
upd
1 parent 82cea82 commit d52d46f

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

plugins/DiscordRPC/src/index.js

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -56,43 +56,45 @@ class WebSocketTransport {
5656
neptune.store.getState().playbackControls.playbackState ==
5757
"NOT_PLAYING";
5858

59-
ws.send(
60-
JSON.stringify({
61-
cmd: "SET_ACTIVITY",
62-
args: {
63-
pid: 2094112,
64-
activity: {
65-
timestamps: {
66-
...(paused
67-
? {}
68-
: {
69-
start: now,
70-
end: remaining,
71-
}),
72-
},
73-
type: 2,
74-
name: formatLongString(currentlyPlaying.title),
75-
details: formatLongString(
76-
"by " + currentlyPlaying.artists.map((a) => a.name).join(", ")
77-
),
78-
assets: {
79-
large_image: `https://resources.tidal.com/images/${currentlyPlaying.album.cover
80-
.split("-")
81-
.join("/")}/80x80.jpg`,
82-
large_text: `on ${formatLongString(
83-
currentlyPlaying.album.title
84-
)}`,
85-
...(paused
86-
? {
87-
small_image: "paused-icon",
88-
small_text: "Paused",
89-
}
90-
: {}),
59+
this.ws.readyState == 1 &&
60+
ws.send(
61+
JSON.stringify({
62+
cmd: "SET_ACTIVITY",
63+
args: {
64+
pid: 2094112,
65+
activity: {
66+
timestamps: {
67+
...(paused
68+
? {}
69+
: {
70+
start: now,
71+
end: remaining,
72+
}),
73+
},
74+
type: 2,
75+
name: formatLongString(currentlyPlaying.title),
76+
details: formatLongString(
77+
"by " +
78+
currentlyPlaying.artists.map((a) => a.name).join(", ")
79+
),
80+
assets: {
81+
large_image: `https://resources.tidal.com/images/${currentlyPlaying.album.cover
82+
.split("-")
83+
.join("/")}/80x80.jpg`,
84+
large_text: `on ${formatLongString(
85+
currentlyPlaying.album.title
86+
)}`,
87+
...(paused
88+
? {
89+
small_image: "paused-icon",
90+
small_text: "Paused",
91+
}
92+
: {}),
93+
},
9194
},
9295
},
93-
},
94-
})
95-
);
96+
})
97+
);
9698
})
9799
);
98100
}

0 commit comments

Comments
 (0)