0

This is my code:

async def tracklooper(ctx, timesPlayedTrack):
    voice = get(bot.voice_clients, guild=ctx.guild)
    if (timesPlayedTrack <= totaltime):
        if voice and voice.is_playing():
            voice.stop()
            print(str(timesPlayedTrack))
            run_coroutine_threadsafe(msg.edit(content="Playing "+vTT+" for "+str(timesPlayedTrack)+" time/s"), bot.loop)
            voice.play(discord.FFmpegPCMAudio(audio), after=lambda e: asyncio.run_coroutine_threadsafe(tracklooper(ctx, timesPlayedTrack+1)), bot.loop)
            voice.is_playing()
    else:
        run_coroutine_threadsafe(msg.delete(), bot.loop)
        run_coroutine_threadsafe(ctx.send("Finished playing "+vTT+" for "+str(totaltime)+" times"), bot.loop)
        run_coroutine_threadsafe(looptrack_set_times.delete(), bot.loop)
        run_coroutine_threadsafe(ply.delete(), bot.loop)

This is the error:

voice.play(discord.FFmpegPCMAudio(audio), after=lambda e: asyncio.run_coroutine_threadsafe(tracklooper(ctx, timesPlayedTrack+1)), bot.loop)
                                                                                                                                      ^
SyntaxError: positional argument follows keyword argument

I am not very familiar with python language so I am having trouble finding the fix.

Sathvik K S
  • 109
  • 1
  • 2
  • 11
  • 1
    Does this answer your question? [positional argument follows keyword argument](https://stackoverflow.com/questions/42163846/positional-argument-follows-keyword-argument) – Svirin Aug 31 '20 at 21:49

1 Answers1

0

Keyword arguments, in your case after=lambda..., should always be placed at the end of the function call. You have put bot.loop at the end, which is not a keyword argument.

Looking at the API docs, the only parameters of VoiceClient.play are the source and after, so you should just remove bot.loop, as you have already provided both parameters.

stijndcl
  • 5,294
  • 1
  • 9
  • 23