mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 21:28:06 +00:00
feat: Add DiscordRichPresence | 增加DiscordRichPresence (#408)
This commit is contained in:
parent
0e6c40f32f
commit
267a678f2a
8 changed files with 151 additions and 9 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { app, ipcMain, dialog } from "electron";
|
||||
import match from "@njzy/unblockneteasemusic";
|
||||
const client = require("discord-rich-presence")("818936529484906596");
|
||||
|
||||
export function initIpcMain(win, store) {
|
||||
ipcMain.on("unblock-music", (event, track) => {
|
||||
|
|
@ -61,4 +62,29 @@ export function initIpcMain(win, store) {
|
|||
ipcMain.on("settings", (event, options) => {
|
||||
store.set("settings", options);
|
||||
});
|
||||
|
||||
ipcMain.on("playDiscordPresence", (event, track) => {
|
||||
client.updatePresence({
|
||||
details: track.name + " - " + track.ar.map((ar) => ar.name).join(","),
|
||||
state: track.al.name,
|
||||
endTimestamp: Date.now() + track.dt,
|
||||
largeImageKey: "logo",
|
||||
largeImageText: "YesPlayMusic",
|
||||
smallImageKey: "play",
|
||||
smallImageText: "Playing",
|
||||
instance: true,
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on("pauseDiscordPresence", (event, track) => {
|
||||
client.updatePresence({
|
||||
details: track.name + " - " + track.ar.map((ar) => ar.name).join(","),
|
||||
state: track.al.name,
|
||||
largeImageKey: "logo",
|
||||
largeImageText: "YesPlayMusic",
|
||||
smallImageKey: "pause",
|
||||
smallImageText: "Pause",
|
||||
instance: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue