![](/img/trans.png)
[英]TypeError at '' __init__() got an unexpected keyword argument ''
[英]TypeError: __init__() got an unexpected keyword argument 'after'
我试图用这段代码重复循环这个函数,这给了我错误的问题。
async def looptrack(ctx, *times):
global timess
voice = get(bot.voice_clients, guild=ctx.guild)
if (ctx.author.voice):
if voice and voice.is_playing():
if os.path.exists(audio):
if times:
times = int(''.join(map(str, times)))
timess = str(times)
if (timess == "0"):
global looptrack_infinite
looptrack_infinite = await ctx.send("Will loop "+vTT+" infinite times")
await tracklooper(0)
else:
global looptrack_set_times
looptrack_set_times = await ctx.send("Will loop "+vTT+" for "+timess+" times")
voice.play(discord.FFmpegPCMAudio(audio, after=lambda e: looptrack(ctx)))
else:
global looptrack_fail
looptrack_fail = await ctx.send("Please enter the number of times to repeat, 0 for infinite times")
await looptrack_fail.delete(delay=10)
else:
global looptrack_no_audio
looptrack_no_audio = await ctx.send("Audio file not found")
await looptrack_no_audio.delete(delay=10)
else:
global looptrack_notin_channel
looptrack_notin_channel = await ctx.send("No song loaded")
await looptrack_notin_channel.delete(delay=10)
else:
looptrack_client_notcn = await ctx.send("You are not connected to any voice channel")
await looptrack_client_notcn.delete(delay=10)
这是我的不和谐机器人代码的一部分,如果调用命令looptrack
,我将尝试在语音通道中重复播放音乐
编辑:按照建议,我替换了该行
voice.play(discord.FFmpegPCMAudio(audio, after=lambda e: looptrack(ctx)))
和
voice.play(discord.FFmpegPCMAudio(audio), after=lambda e: looptrack(ctx))
现在抛出一个新错误
Warning: coroutine 'Command.__call__' was never awaited
self.after(error)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
将出现错误的行替换为:
voice.play(discord.FFmpegPCMAudio(audio), after=lambda e: looptrack(ctx))
你把一个右括号放在错误的地方。 after
应该是要play
的参数,而不是FFmpegPCMAudio
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.