Open Fyphen1223 opened 1 year ago
You probably have an undefined variable somewhere in your code. I wouldn't know though because there is no code to look at.
The same happens here.
Here is the code I'm trying to execute:
import play from "play-dl";
if(play.is_expired) await play.refreshToken()
console.log(await play.spotify('https://open.spotify.com/track/3m8UfZwPMMbiWfGR8Lg2cR?si=ee01102c58724355'))
Here is the stack:
TypeError: Cannot read properties of undefined (reading 'spotify')
at new SpotifyTrack (/hd/dev/tortuga-bot/node_modules/play-dl/dist/index.js:7:23462)
at Object.spotify (/hd/dev/tortuga-bot/node_modules/play-dl/dist/index.js:10:382)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///hd/dev/tortuga-bot/test.js:4:13
The error is thrown in the constructor of SpotifyTrack E=class{constructor(e){this.name=e.name,this.id=e.id,this.type="track",this.url=e.external_urls.spotify,...
, where e.external_urls.spotify
is 'undefined'.
Node.js v19.6.0 "play-dl": "^1.9.6"
I'm having the same issue as the @PedroVH (having reviewed his code on GitHub, it's very similar to mine and seems to follow the guides). I notice he doesn't seem to ever have found a fix for it, and I can't find any other threads that seem to still be relevant to this particular issue.
Node.js v19.6.0 "play-dl": "^1.9.6"
I've run the authorize.js
step.
Initialising Spotify:
private async initialiseSpotify(): Promise<void> {
this.logger.log('Initialising spotify.');
await play.setToken({
spotify: {
client_id: process.env.SPOTIFY_CLIENT_ID as string,
client_secret: process.env.SPOTIFY_CLIENT_SECRET as string,
refresh_token: process.env.SPOTIFY_REFRESH_TOKEN as string,
market: process.env.SPOTIFY_MARKET as string
},
useragent: ['DinnerJacket']
});
this.logger.log('Spotify initialisation complete.');
}
Fetching a Spotify Track:
if (!spotify) {
this.logger.warn('Spotify service is not set up.');
}
if (play.is_expired()) {
this.logger.log('Spotify authentication expired, refreshing token.');
const success = await play.refreshToken();
this.logger.log(`Token refresh ${success ? 'successful' : 'failure'}.`);
}
let stream = await spotify(url);
When fetching the track I get the below Error (note that I even check for the Spotify object) so it appears to be some internal reference to spotify that's missing even after setting the token:
TypeError: Cannot read properties of undefined (reading 'spotify')
at new SpotifyTrack (PROJECT_DIR\node_modules\play-dl\dist\index.js:7:23462)
at spotify (PROJECT_DIR\node_modules\play-dl\dist\index.js:10:382)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async AudioManager.buildSpotifyTrack (PROJECT_DIR\dist\client\audio\AudioManager.js:134:22)
Describe the bug
Actual behavior
Expected behavior
#### Code to reproduce ```js ``` #### ScreenShotsChecklist