我自己无法解决这个问题,我几乎尝试了我能做的一切,我希望有解决办法。
我的 Discord VC-Bot 有以下播放命令,它连接到节点和所有内容。我得到 TypeError: Type must meet VoiceProtocol 抽象基类。 -错误。
目的地是这种类型:
请帮助前辈
@bot.slash_command(guild_ids=[insert ID])
async def play(interaction : nextcord.Interaction, search : str):
query = await wavelink.YouTubeTrack.search(search, return_first=True)
if not interaction.user.voice or not interaction.user.voice.channel:
await interaction.response.send_message("You need to be in a voice channel to use this command.")
return
destination: nextcord.Voicechannel = interaction.user.voice.channel
if not interaction.guild.voice_client:
vc: wavelink.Player = await destination.connect(cls=wavelink.Player)
#This line breaks my Code and gives me the Type error
else:
vc: wavelink.Player = interaction.guild.voice_client
if vc.queue.is_empty and not vc.is_playing():
await vc.play(query)
await interaction.response.send_message(f"next disk {vc.current.title}")
else:
await vc.queue.put_wait(query)
await interaction.response.send_message(f"playing track")
I tried installing pip install -U nextcord[voice]
首先。你能试试吗:
目的地:nextcord.VoiceChannel = interaction.user.voice.channel
然后,如果它仍然不起作用。您应该尝试使用 VS Code 中的
RUN AND DEBUG
并查看给出错误的确切时刻以及变量的值是什么。
如果错误仍然存在并且您想再次寻求帮助,请尽可能发送原始 Traceback。
我希望有完整的追溯?如果我说了一些愚蠢的话,请原谅我,我是一个编码傻瓜,我正在努力学习,但我想我只是把一切都弄错了
所以这里回溯
Traceback (most recent call last):
File "C:\Users\mydcbot\mydcbot.py", line 60, in play
vc: wavelink.Player = await destination.connect(cls=wavelink.Player)
File "C:\Users\.conda\envs\py310\lib\site-packages\nextcord\abc.py", line 1771, in connect
raise TypeError("Type must meet VoiceProtocol abstract base class.")
TypeError: Type must meet VoiceProtocol abstract base class.