Python SyntaxError:位置参数跟在关键字参数[discord.py]后面
这是我的代码:Python SyntaxError:位置参数跟在关键字参数[discord.py]后面,python,python-3.x,discord.py,discord.py-rewrite,Python,Python 3.x,Discord.py,Discord.py Rewrite,这是我的代码: 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(timesPlayedTr
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)
我对python语言不太熟悉,因此在查找修复程序时遇到困难。关键字参数,在您的例子中,
after=lambda…
,应该始终放在函数调用的末尾。您已将bot.loop
放在末尾,它不是关键字参数
查看API文档,
VoiceClient.play
的唯一参数是源代码和后的,因此您应该删除bot.loop
,因为您已经提供了这两个参数。这是否回答了您的问题?
voice.play(discord.FFmpegPCMAudio(audio), after=lambda e: asyncio.run_coroutine_threadsafe(tracklooper(ctx, timesPlayedTrack+1)), bot.loop)
^
SyntaxError: positional argument follows keyword argument