This repository was archived by the owner on Apr 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed
samples/spotify-current-song Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ import { NodeCG } from "nodecg/types/server" ;
2+ import { requireService } from "nodecg-io-core/extension/serviceClientWrapper" ;
3+ import { SpotifyServiceClient } from "nodecg-io-spotify" ;
4+
5+ module . exports = function ( nodecg : NodeCG ) {
6+ nodecg . log . info ( "Sample bundle for spotify started" ) ;
7+
8+ const service = requireService < SpotifyServiceClient > ( nodecg , "spotify" ) ;
9+ service ?. onAvailable ( async ( client ) => {
10+ nodecg . log . info ( "Client has been updated." ) ;
11+
12+ const track = await client . getNativeClient ( ) . getMyCurrentPlayingTrack ( ) ;
13+ const name = track . body . item ?. name ;
14+ const artists = track . body . item ?. artists . map ( ( a ) => a . name ) ;
15+ nodecg . log . info ( `Currently playing "${ name } " by "${ artists } ".` ) ;
16+ } ) ;
17+
18+ service ?. onUnavailable ( ( ) => nodecg . log . info ( "Client has been unset." ) ) ;
19+ } ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " spotify-current-song" ,
3+ "private" : true ,
4+ "version" : " 0.1.0" ,
5+ "nodecg" : {
6+ "compatibleRange" : " ^1.1.1" ,
7+ "bundleDependencies" : {
8+ "nodecg-io-spotify" : " ^0.1.0"
9+ }
10+ },
11+ "scripts" : {
12+ "build" : " tsc -b" ,
13+ "watch" : " tsc -b -w" ,
14+ "clean" : " tsc -b --clean"
15+ },
16+ "license" : " MIT" ,
17+ "dependencies" : {
18+ "nodecg-io-spotify" : " ^0.1.0" ,
19+ "nodecg-io-core" : " ^0.1.0" ,
20+ "@types/node" : " ^14.14.13" ,
21+ "nodecg" : " ^1.7.4" ,
22+ "typescript" : " ^4.1.3"
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ {
2+ "extends" : " ../../tsconfig.common.json"
3+ }
You can’t perform that action at this time.
0 commit comments