I'm trying to make a Blind-test bot game in Python, which actually works pretty fine. I managed to get a whole spotify playlist in the queue with that play_next() function.
def play_next(ctx):
if len(song_queue) >= 1:
del song_queue[0]
source = song_queue[0]
vc.play(FFmpegPCMAudio(source=source.preview_url),
after=lambda e: play_next(ctx))
track_played = source
@client.command()
async def start(ctx):
...
...
for song in tracks:
if not song.track.preview_url:
continue
source = song.track
song_queue.append(source)
if not vc.is_playing():
vc.play(FFmpegPCMAudio(source=source.preview_url),
after=lambda e: play_next(ctx))
track_played = source
As soon I turn the play_next() function to async to output details about the tracks being played, problems start.
async def play_next(ctx):
await ctx.send("The answer was: {} from {}".format(track_played.name,
' and'.join(track_played.artists)))
if len(song_queue) >= 1:
del song_queue[0]
source = song_queue[0]
await ctx.send('Next song is about to start')
vc.play(FFmpegPCMAudio(source=source.preview_url),
after=lambda e: play_next(ctx))
track_played = source
Running the previous code throws me this error:
play_next() was never awaited
How can I solve this?