![](/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.