Comparing version 0.2.22 to 0.2.23
@@ -44,7 +44,7 @@ #!/usr/bin/env node | ||
details: `🎵 Song - ${res.track.track_resource.name}`, | ||
state: `👤 Artist - ${res.track.artist_resource.name}`, | ||
state: `👤 Artist - ${res.track.artist_resource ? res.track.artist_resource.name : ''}`, | ||
startTimestamp: start, | ||
endTimestamp: end, | ||
largeImageKey: 'spotifylarge', | ||
largeImageText: `💿 Album - ${res.track.album_resource.name}`, | ||
largeImageText: `💿 Album - ${res.track.album_resource ? res.track.album_resource.name : ''}`, | ||
smallImageKey: 'playing', | ||
@@ -54,3 +54,3 @@ smallImageText: 'Playing', | ||
}); | ||
logger.info(`(${new Date().toLocaleTimeString()}) Updated Song - ${res.track.track_resource.name} by ${res.track.artist_resource.name}`); | ||
logger.info(`(${new Date().toLocaleTimeString()}) Updated Song - ${res.track.track_resource.name} by ${res.track.artist_resource ? res.track.artist_resource.name : ''}`); | ||
} | ||
@@ -77,20 +77,22 @@ else { | ||
; | ||
function checkVersion() { | ||
return new Promise((resolve, reject) => { | ||
let sVersion = require('../package.json').version; | ||
let version = ~~(require('../package.json').version.split('.').join('')); | ||
axios_1.default.get('https://raw.githubusercontent.com/KurozeroPB/discotify/master/package.json') | ||
.then((res) => { | ||
if (res.status !== 200) { | ||
return reject(new Error(`Failed to check for updates: ${res.data}`)); | ||
async function checkVersion() { | ||
let sVersion = require('../package.json').version; | ||
let version = ~~(require('../package.json').version.split('.').join('')); | ||
axios_1.default.get('https://raw.githubusercontent.com/KurozeroPB/discotify/cli/package.json') | ||
.then((res) => { | ||
if (res.status !== 200) { | ||
logger.error(`Failed to check for updates: ${res.data}`); | ||
} | ||
else { | ||
let latest = ~~(res.data.version.split('.').join('')); | ||
if (latest > version) { | ||
logger.error(`A new version of Discotify is avalible\nPlease get the latest version from: https://www.npmjs.com/package/discotify\nOr run npm install -g discotify@${res.data.version}`); | ||
kill(); | ||
} | ||
else { | ||
let latest = ~~(res.data.version.split('.').join('')); | ||
if (latest > version) | ||
return reject(new Error(`A new version of Discotify is avalible\nPlease get the latest version from: https://www.npmjs.com/package/discotify\nOr run npm install -g discotify@${res.data.version}`)); | ||
return resolve(`Discotify is up-to-date using v${sVersion}`); | ||
logger.info(`Discotify is up-to-date using v${sVersion}`); | ||
} | ||
}).catch((err) => { | ||
return reject(new Error(err.stack ? err.stack : err.message ? err.message : err.toString())); | ||
}); | ||
} | ||
}).catch((err) => { | ||
logger.error(err.stack ? err.stack : err.message ? err.message : err.toString()); | ||
}); | ||
@@ -110,10 +112,9 @@ } | ||
const [, , ...args] = process.argv; | ||
if (args[0] && args[0].toLowerCase() === "start") { | ||
if ((args[0]) && (args[0].toLowerCase() === "--start" || args[0].toLowerCase() === "-s")) { | ||
rpc.on('ready', async () => { | ||
try { | ||
const resp = await checkVersion(); | ||
logger.info(resp); | ||
await checkVersion(); | ||
} | ||
catch (e) { | ||
return logger.error(e.message ? e.message : e); | ||
return logger.error(e); | ||
} | ||
@@ -129,12 +130,40 @@ logger.info(`Connected with ID: ${clientID}`); | ||
} | ||
else if ((args[0]) && (args[0].toLowerCase() === "--help" || args[0].toLowerCase() === "-h")) { | ||
console.log(` | ||
_____ _ _ _ __ | ||
| __ \\(_) | | (_)/ _| | ||
| | | |_ ___ ___ ___ | |_ _| |_ _ _ | ||
| | | | / __|/ __/ _ \\| __| | _| | | | | ||
| |__| | \\__ \\ (_| (_) | |_| | | | |_| | | ||
|_____/|_|___/\\___\\___/ \\__|_|_| \\__, | | ||
__/ | | ||
|___/ | ||
_______________________________________ | ||
| | | ||
| discotify [option] | | ||
| Options: | | ||
| --start/-s Start the script | | ||
| --help/-h Show this message | | ||
|_______________________________________| | ||
`); | ||
} | ||
else { | ||
console.log(` | ||
_____ _ _ _ __ | ||
| __ \\(_) | | (_)/ _| | ||
| | | |_ ___ ___ ___ | |_ _| |_ _ _ | ||
| | | | / __|/ __/ _ \\| __| | _| | | | | ||
| |__| | \\__ \\ (_| (_) | |_| | | | |_| | | ||
|_____/|_|___/\\___\\___/ \\__|_|_| \\__, | | ||
__/ | | ||
|___/ | ||
_______________________________________ | ||
| | | ||
| discotify start - to start the script | | ||
| discotify [option] | | ||
| Options: | | ||
| --start/-s Start the script | | ||
| --help/-h Show this message | | ||
|_______________________________________| | ||
`); | ||
} | ||
process.on('SIGINT', () => { | ||
kill(); | ||
}); | ||
process.on('SIGINT', () => kill()); |
82
index.ts
@@ -46,7 +46,7 @@ #!/usr/bin/env node | ||
details: `🎵 Song - ${res.track.track_resource.name}`, | ||
state: `👤 Artist - ${res.track.artist_resource.name}`, | ||
state: `👤 Artist - ${res.track.artist_resource ? res.track.artist_resource.name : ''}`, | ||
startTimestamp: start, | ||
endTimestamp: end, | ||
largeImageKey: 'spotifylarge', | ||
largeImageText: `💿 Album - ${res.track.album_resource.name}`, | ||
largeImageText: `💿 Album - ${res.track.album_resource ? res.track.album_resource.name : ''}`, | ||
smallImageKey: 'playing', | ||
@@ -57,3 +57,3 @@ smallImageText: 'Playing', | ||
logger.info(`(${new Date().toLocaleTimeString()}) Updated Song - ${res.track.track_resource.name} by ${res.track.artist_resource.name}`); | ||
logger.info(`(${new Date().toLocaleTimeString()}) Updated Song - ${res.track.track_resource.name} by ${res.track.artist_resource ? res.track.artist_resource.name : ''}`); | ||
} else { | ||
@@ -80,19 +80,21 @@ if (compare === true) return; | ||
function checkVersion(): Promise<any> { | ||
return new Promise((resolve, reject) => { | ||
let sVersion: string = require('../package.json').version; | ||
let version = ~~(require('../package.json').version.split('.').join('')); | ||
axios.get('https://raw.githubusercontent.com/KurozeroPB/discotify/master/package.json') | ||
.then((res: AxiosResponse) => { | ||
if (res.status !== 200) { | ||
return reject(new Error(`Failed to check for updates: ${res.data}`)); | ||
async function checkVersion(): Promise<void> { | ||
let sVersion: string = require('../package.json').version; | ||
let version = ~~(require('../package.json').version.split('.').join('')); | ||
axios.get('https://raw.githubusercontent.com/KurozeroPB/discotify/cli/package.json') | ||
.then((res: AxiosResponse) => { | ||
if (res.status !== 200) { | ||
logger.error(`Failed to check for updates: ${res.data}`); | ||
} else { | ||
let latest = ~~(res.data.version.split('.').join('')); | ||
if (latest > version) { | ||
logger.error(`A new version of Discotify is avalible\nPlease get the latest version from: https://www.npmjs.com/package/discotify\nOr run npm install -g discotify@${res.data.version}`); | ||
kill(); | ||
} else { | ||
let latest = ~~(res.data.version.split('.').join('')); | ||
if (latest > version) return reject(new Error(`A new version of Discotify is avalible\nPlease get the latest version from: https://www.npmjs.com/package/discotify\nOr run npm install -g discotify@${res.data.version}`)); | ||
return resolve(`Discotify is up-to-date using v${sVersion}`); | ||
logger.info(`Discotify is up-to-date using v${sVersion}`); | ||
} | ||
}).catch((err: AxiosError) => { | ||
return reject(new Error(err.stack ? err.stack : err.message ? err.message : err.toString())); | ||
}); | ||
}); | ||
} | ||
}).catch((err: AxiosError) => { | ||
logger.error(err.stack ? err.stack : err.message ? err.message : err.toString()); | ||
}); | ||
}; | ||
@@ -112,9 +114,8 @@ | ||
if (args[0] && args[0].toLowerCase() === "start") { | ||
if ((args[0]) && (args[0].toLowerCase() === "--start" || args[0].toLowerCase() === "-s")) { | ||
rpc.on('ready', async () => { | ||
try { | ||
const resp = await checkVersion(); | ||
logger.info(resp); | ||
await checkVersion(); | ||
} catch (e) { | ||
return logger.error(e.message ? e.message : e); | ||
return logger.error(e); | ||
} | ||
@@ -131,7 +132,38 @@ | ||
.catch((err: Error) => logger.error(err.stack ? err.stack : err.toString())); | ||
} else if ((args[0]) && (args[0].toLowerCase() === "--help" || args[0].toLowerCase() === "-h")) { | ||
console.log(` | ||
_____ _ _ _ __ | ||
| __ \\(_) | | (_)/ _| | ||
| | | |_|___ ___ ___ | |_|_| |_ _ _ | ||
| | | | / __|/ __/ _ \\| __| | _| | | | | ||
| |__| | \\__ \\ (_| (_) | |_| | | | |_| | | ||
|_____/|_|___/\\___\\___/ \\__|_|_| \\__, | | ||
__/ | | ||
|___/ | ||
_______________________________________ | ||
| | | ||
| discotify [option] | | ||
| | | ||
| Options: | | ||
| --start/-s Start the script | | ||
| --help/-h Show this message | | ||
|_______________________________________| | ||
`); | ||
} else { | ||
console.log(` | ||
_____ _ _ _ __ | ||
| __ \\(_) | | (_)/ _| | ||
| | | |_|___ ___ ___ | |_|_| |_ _ _ | ||
| | | | / __|/ __/ _ \\| __| | _| | | | | ||
| |__| | \\__ \\ (_| (_) | |_| | | | |_| | | ||
|_____/|_|___/\\___\\___/ \\__|_|_| \\__, | | ||
__/ | | ||
|___/ | ||
_______________________________________ | ||
| | | ||
| discotify start - to start the script | | ||
| discotify [option] | | ||
| | | ||
| Options: | | ||
| --start/-s Start the script | | ||
| --help/-h Show this message | | ||
|_______________________________________| | ||
@@ -141,4 +173,2 @@ `); | ||
process.on('SIGINT', () => { | ||
kill(); | ||
}); | ||
process.on('SIGINT', () => kill()); |
{ | ||
"name": "discotify", | ||
"version": "0.2.22", | ||
"version": "0.2.23", | ||
"description": "Discord Rich Presence for spotify in TypeScript", | ||
@@ -5,0 +5,0 @@ "homepage": "https://kurozero.xyz", |
@@ -15,3 +15,3 @@ <div align="center"> | ||
# discotify `0.2.22` | ||
# discotify `0.2.23` | ||
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.2.22` | ||
`npm install -g discotify@0.2.23` | ||
@@ -31,5 +31,2 @@ ## Requirements | ||
- Spotify: [win](https://www.spotify.com/nl/download/windows/), [linux](https://www.spotify.com/nl/download/linux/), [osx](https://www.spotify.com/nl/download/mac/) | ||
- You might additionally have to install ts-node and typescript globally | ||
- ts-node: `npm install -g ts-node` | ||
- typescript: `npm install -g typescript` | ||
@@ -36,0 +33,0 @@ ## Usage |
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
77810
12
1156
48