Comparing version 0.3.11 to 0.3.21
#!/usr/bin/env node | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const DiscordRPC = require("discord-rpc"); | ||
const logger = require("winston"); | ||
@@ -16,4 +15,4 @@ const axios_1 = require("axios"); | ||
const spotify = new nodeSpotifyWebhelper.SpotifyWebHelper(); | ||
const rpc = new DiscordRPC.Client({ transport: 'ipc' }); | ||
const clientID = '383639700994523137'; | ||
const client = require('discord-rich-presence')(clientID); | ||
let compareURI; | ||
@@ -54,3 +53,2 @@ let compare; | ||
} | ||
; | ||
async function xmasAlbumCheck(albumName) { | ||
@@ -71,5 +69,4 @@ let bool; | ||
} | ||
; | ||
function updateRichPresence() { | ||
if (!rpc) | ||
if (!client) | ||
return; | ||
@@ -114,3 +111,3 @@ spotify.getStatus(async (err, res) => { | ||
} | ||
rpc.setActivity({ | ||
client.updatePresence({ | ||
details: `🎵 Song - ${songName}`, | ||
@@ -133,3 +130,3 @@ state: `👤 Artist - ${songArtist}`, | ||
compareURI = ''; | ||
rpc.setActivity({ | ||
client.updatePresence({ | ||
details: `Paused`, | ||
@@ -171,16 +168,11 @@ startTimestamp: 0, | ||
} | ||
; | ||
function kill() { | ||
rpc.destroy() | ||
.then(() => { | ||
process.exit(0); | ||
setTimeout(() => { | ||
process.exit(0); | ||
setTimeout(() => { | ||
process.exit(0); | ||
}, 5000); | ||
}).catch((err) => logger.error(err.stack ? err.stack : err.toString())); | ||
}, 5000); | ||
} | ||
; | ||
const [, , ...args] = process.argv; | ||
if ((args[0]) && (args[0].toLowerCase() === "--start" || args[0].toLowerCase() === "-s")) { | ||
rpc.on('ready', async () => { | ||
(async () => { | ||
try { | ||
@@ -192,10 +184,6 @@ await checkVersion(); | ||
} | ||
logger.info(`Connected with ID: ${clientID}`); | ||
})(); | ||
setInterval(() => { | ||
updateRichPresence(); | ||
setInterval(() => { | ||
updateRichPresence(); | ||
}, 1500); | ||
}); | ||
rpc.login(clientID) | ||
.catch((err) => logger.error(err.stack ? err.stack : err.toString())); | ||
}, 1500); | ||
} | ||
@@ -202,0 +190,0 @@ else if ((args[0]) && (args[0].toLowerCase() === "--help" || args[0].toLowerCase() === "-h")) { |
85
index.ts
#!/usr/bin/env node | ||
import * as DiscordRPC from 'discord-rpc'; | ||
import * as logger from 'winston'; | ||
@@ -16,4 +15,5 @@ import axios, { AxiosError, AxiosResponse } from 'axios'; | ||
const spotify = new nodeSpotifyWebhelper.SpotifyWebHelper(); | ||
const rpc = new DiscordRPC.Client({ transport: 'ipc' }); | ||
const clientID = '383639700994523137'; | ||
const client = require('discord-rich-presence')(clientID); | ||
@@ -56,3 +56,3 @@ let compareURI: string; | ||
return bool; | ||
}; | ||
} | ||
@@ -71,6 +71,6 @@ async function xmasAlbumCheck(albumName: string): Promise<boolean> { | ||
return bool; | ||
}; | ||
} | ||
function updateRichPresence() { | ||
if (!rpc) return; | ||
if (!client) return; | ||
@@ -114,13 +114,13 @@ spotify.getStatus(async (err: Error, res: any) => { | ||
rpc.setActivity({ | ||
details: `🎵 Song - ${songName}`, | ||
state: `👤 Artist - ${songArtist}`, | ||
startTimestamp: start, | ||
endTimestamp: end, | ||
largeImageKey: largeImage, | ||
largeImageText: `💿 Album - ${songAlbum}`, | ||
smallImageKey: 'playing', | ||
smallImageText: 'Playing', | ||
instance: false, | ||
}); | ||
client.updatePresence({ | ||
details: `🎵 Song - ${songName}`, | ||
state: `👤 Artist - ${songArtist}`, | ||
startTimestamp: start, | ||
endTimestamp: end, | ||
largeImageKey: largeImage, | ||
largeImageText: `💿 Album - ${songAlbum}`, | ||
smallImageKey: 'playing', | ||
smallImageText: 'Playing', | ||
instance: false, | ||
}); | ||
@@ -133,12 +133,12 @@ logger.info(`(${new Date().toLocaleTimeString()}) Updated Song - ${res.track.track_resource.name} by ${res.track.artist_resource ? res.track.artist_resource.name : ''}`); | ||
rpc.setActivity({ | ||
details: `Paused`, | ||
startTimestamp: 0, | ||
endTimestamp: 0, | ||
largeImageKey: 'spotifylarge', | ||
largeImageText: '---', | ||
smallImageKey: 'paused', | ||
smallImageText: 'Paused', | ||
instance: false | ||
}); | ||
client.updatePresence({ | ||
details: `Paused`, | ||
startTimestamp: 0, | ||
endTimestamp: 0, | ||
largeImageKey: 'spotifylarge', | ||
largeImageText: '---', | ||
smallImageKey: 'paused', | ||
smallImageText: 'Paused', | ||
instance: false | ||
}); | ||
@@ -169,7 +169,5 @@ logger.info(`(${new Date().toLocaleTimeString()}) Spotify is paused`); | ||
}); | ||
}; | ||
} | ||
function kill() { | ||
rpc.destroy() | ||
.then(() => { | ||
process.exit(0); | ||
@@ -179,4 +177,3 @@ setTimeout(() => { | ||
}, 5000); | ||
}).catch((err) => logger.error(err.stack ? err.stack : err.toString())); | ||
}; | ||
} | ||
@@ -186,18 +183,12 @@ const [, , ...args] = process.argv; | ||
if ((args[0]) && (args[0].toLowerCase() === "--start" || args[0].toLowerCase() === "-s")) { | ||
rpc.on('ready', async () => { | ||
try { | ||
await checkVersion(); | ||
} catch (e) { | ||
return logger.error(e); | ||
} | ||
logger.info(`Connected with ID: ${clientID}`); | ||
updateRichPresence(); | ||
setInterval(() => { | ||
updateRichPresence(); | ||
}, 1500); | ||
}); | ||
rpc.login(clientID) | ||
.catch((err: Error) => logger.error(err.stack ? err.stack : err.toString())); | ||
(async () => { | ||
try { | ||
await checkVersion(); | ||
} catch (e) { | ||
return logger.error(e); | ||
} | ||
})(); | ||
setInterval(() => { | ||
updateRichPresence(); | ||
}, 1500); | ||
} else if ((args[0]) && (args[0].toLowerCase() === "--help" || args[0].toLowerCase() === "-h")) { | ||
@@ -204,0 +195,0 @@ console.log(` |
{ | ||
"name": "discotify", | ||
"version": "0.3.11", | ||
"version": "0.3.21", | ||
"description": "Discord Rich Presence for spotify in TypeScript", | ||
@@ -34,3 +34,4 @@ "homepage": "https://kurozero.xyz", | ||
"axios": "^0.17.1", | ||
"discord-rpc": "^3.0.0-beta.6", | ||
"discord-rich-presence": "0.0.6", | ||
"discord-rpc": "^3.0.0-beta.8", | ||
"request": "^2.83.0", | ||
@@ -37,0 +38,0 @@ "winston": "^2.4.0" |
@@ -15,3 +15,3 @@ <div align="center"> | ||
# discotify `0.3.11` | ||
# discotify `0.3.21` | ||
Spotify Rich Presence for Discord in TypeScript<br/> | ||
@@ -21,3 +21,3 @@ *shows your currently playing song as a fancy rich presence in Discord* | ||
Install globally with:<br/> | ||
`npm install -g discotify@0.3.11` | ||
`npm install -g discotify@0.3.21` | ||
@@ -24,0 +24,0 @@ ## Requirements |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96987
17
5
1266
+ Addeddiscord-rich-presence@0.0.6
+ Addeddiscord-rich-presence@0.0.6(transitive)
Updateddiscord-rpc@^3.0.0-beta.8