Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
Discord Music Bot Youtube Playlists not working

Hello I am trying to solve a problem with a Discord Music Bot, it works fine with Spotify songs and playlists, but Youtube playlists no (although songs it does work). I can add song by song to the queue but not a list.

This is the error:

music_message 476:TypeError: arr is not iterable

in this part of the code:

 if (isYoutube(qry) && isYoutubePlaylist(qry)) {
     try {
         const arr = await youtube_tracks_from_playlist(qry);
         for (let item of arr)
             addToQueue(item, mapKey)
         message.react(EMOJI_GREEN_CIRCLE)
     } catch (e) {
         console.log('music_message 476:' + e)
         message.channel.send('Failed to process playlist: ' + qry);
     }
 }

But due to the fact that the error is that it cannot be iterated I guess the error comes from before and the format of the object. So here is the function:

async function youtube_tracks_from_playlist(url, isretry=false) {
    const data = await ytlist(url, 'url');
    console.log("Type of youtube data: " + typeof data)
    console.log("Data: " + data)
    if (data && 'data' in data && 'playlist' in data.data && data.data.playlist && data.data.playlist.length) {
        return data.data.playlist
    } else {
        if (!isretry) {
            console.log('retrying yt playlist processing')
            return await youtube_tracks_from_playlist(url, true);
        } else {
            return null;
        }
    }
}

And in case it helps here are the outputs of the console to types of data and ytlist def:

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

Type of youtube data: object

Data: [object Object]

Type of arr: object

arr: null

So, I have no clue if that [object Object] is the common thing I am supposed to get, or what is the problem?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!