Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limited to One Playlist #17

Closed
Gekocaretaker opened this issue Sep 1, 2020 · 5 comments
Closed

Limited to One Playlist #17

Gekocaretaker opened this issue Sep 1, 2020 · 5 comments

Comments

@Gekocaretaker
Copy link

If I try to use this module for multiple playlist, it causes an error. I even tried calling the module in 2 different const, but it just causes the same issues.

@CodeDotJS
Copy link
Owner

How you're doing it? Please paste the code here.

@Gekocaretaker
Copy link
Author

This is the file. I am using it for discord js.
https://github.com/Gekocaretaker/Lizz-AI/blob/master/commands/video.js

@CodeDotJS
Copy link
Owner

All the problems are related to scope. Please have a look here

For example -

In order to fetch contents from two playlist, you've to do -

const ytlist = require('youtube-playlist');

ytlist(urlOne, 'url').then(urlOneContent => {
  ytlist(urlTwo, 'url').then(urlTwoContent => {
    const urlOneData = urlOneContent.data.playlist;
    const urlTwoData = urlTwoContent.data.playlist;
    // do something with the available data
  });
});

In your code, you're doing -

moronsPlaylist(moronsUrl, 'url').then(res => {
  ranYtVid = res.data.playlist;
});

solidslicerPlaylist(solidslicerUrl, 'url').then(res => {
  ranYtVid2 = res.data.playlist;
});

You've trying to access ranYtVid and ranYtVid2 inside -

if(args[0] === '107Morons') { }

You'll end up getting reference error.

Hope this helps.

@Gekocaretaker
Copy link
Author

It works perfectly. But now I am getting this error: "Cannot read property 'send' of undefined at /app/commands/video.js:32:19"
And I don't know what is wrong.

@CodeDotJS
Copy link
Owner

The problem is not related to this module, so I'm closing the issue. Will be happy to clear the doubts though.

Also, try to debug the code - use console.log(message.channel) to see what you're getting here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants