mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Added Discord timeout
This commit is contained in:
@ -35,6 +35,10 @@ const defaultConfig = {
|
|||||||
ffmpegArgs: [], // e.g. ["-b:a", "192k"] for an audio bitrate of 192kb/s
|
ffmpegArgs: [], // e.g. ["-b:a", "192k"] for an audio bitrate of 192kb/s
|
||||||
downloadFolder: undefined, // Custom download folder (absolute path)
|
downloadFolder: undefined, // Custom download folder (absolute path)
|
||||||
},
|
},
|
||||||
|
discord: {
|
||||||
|
activityTimoutEnabled: true, // if enabled, the discord rich presence gets cleared when music paused after the time specified below
|
||||||
|
activityTimoutTime: 10 * 60 * 1000 // 10 minutes
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,9 @@ const rpc = new Discord.Client({
|
|||||||
// Application ID registered by @semvis123
|
// Application ID registered by @semvis123
|
||||||
const clientId = "790655993809338398";
|
const clientId = "790655993809338398";
|
||||||
|
|
||||||
module.exports = (win) => {
|
let clearActivity;
|
||||||
|
|
||||||
|
module.exports = (win, {activityTimoutEnabled, activityTimoutTime}) => {
|
||||||
const registerCallback = getSongInfo(win);
|
const registerCallback = getSongInfo(win);
|
||||||
|
|
||||||
// If the page is ready, register the callback
|
// If the page is ready, register the callback
|
||||||
@ -29,7 +31,13 @@ module.exports = (win) => {
|
|||||||
// Add an idle icon to show that the song is paused
|
// Add an idle icon to show that the song is paused
|
||||||
activityInfo.smallImageKey = "idle";
|
activityInfo.smallImageKey = "idle";
|
||||||
activityInfo.smallImageText = "idle/paused";
|
activityInfo.smallImageText = "idle/paused";
|
||||||
|
// Set start the timer so the activity gets cleared after a while if enabled
|
||||||
|
if (activityTimoutEnabled)
|
||||||
|
clearActivity = setTimeout(()=>rpc.clearActivity(), activityTimoutTime||10,000);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// stop the clear activity timout
|
||||||
|
clearTimeout(clearActivity);
|
||||||
// Add the start and end time of the song
|
// Add the start and end time of the song
|
||||||
const songStartTime = Date.now() - songInfo.elapsedSeconds * 1000;
|
const songStartTime = Date.now() - songInfo.elapsedSeconds * 1000;
|
||||||
activityInfo.startTimestamp = songStartTime;
|
activityInfo.startTimestamp = songStartTime;
|
||||||
|
|||||||
Reference in New Issue
Block a user