How to play next song in queue when the first song finished discord bot

  discord.py, python

I want to make my discord music bot be able to play the next song in queue right after the fist song finished. Is there any way to do that?

This is my play function

queue = []

@client.command(name='play',help ='Play a song',aliases=['plays', 'p'])
async def play(ctx, url):
    global queue
    server = ctx.message.guild
    voice_channel = server.voice_client
    queue.append(url)
    async with ctx.typing():
        player = await YTDLSource.from_url(queue[0], loop=client.loop)
        voice_channel.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
        del(queue[0])
        await ctx.send(f'**Now playing:** {player.title}')

Source: Python Questions

LEAVE A COMMENT