Raptor123471 / DingoLingo

A Discord music bot written in Python with support for Youtube, SoundCloud, Spotify, Bandcamp, Twitter, and custom files.
GNU General Public License v3.0
282 stars 165 forks source link

Pagination in queue #64

Closed Vaibhav5757 closed 2 years ago

Vaibhav5757 commented 2 years ago

Can we have the feature to add pagination in the queue? I forked the repo and I tried it over the last weekend. I was able to make multiple embeds with each embed having 25 fields. But after the first embed, other embeds don't have song names coming, just the link is showing.

for counter, song in enumerate(list(playlist.playque), start=1):
            if song.info.title is None:
                embed.add_field(
                    name="\u200b",
                    value="{}.".format(str(counter))
                    + " "
                    + "[{}]({})".format(song.info.webpage_url, song.info.webpage_url),
                    inline=False,
                )
            else:
                embed.add_field(
                    name="\u200b",
                    value="{}.".format(str(counter))
                    + " "
                    + "[{}]({})".format(song.info.title, song.info.webpage_url),
                    inline=False,
                )
            # Add a new embed if count of 25 is reached
            if (
                counter > config.MAX_SONG_PRELOAD
                and counter % config.MAX_SONG_PRELOAD == 0
            ):
                embeds.append(embed)
                embed = discord.Embed(
                    title=":scroll: Queue [{}]".format(len(playlist.playque)),
                    color=config.EMBED_COLOR,
                    inline=False,
                )
            # Add the remaining songs in a seperate embed
            if counter == len(list(playlist.playque)):
                embeds.append(embed)

        for embed in embeds:
            await ctx.send(embed=embed)

Paginator code is still messy so not adding it

Raptor123471 commented 2 years ago

This happens because the max song preload is set at 25. For this to work either all songs would need to be preloaded at once or would need to be preloaded on the fly by the queue pagination.

Vaibhav5757 commented 2 years ago

Got it. I forked the repo and added the feature @https://github.com/Vaibhav5757/DingoLingo. It's still buggy and had to preload the complete playlist at once. Couldn't figure out how to do it on request.