我的代码使机器人加入 vc,但它不播放音乐,机器人也给出以下错误,我不明白,我真的需要帮助修复错误:(
Ignoring exception in command play
Traceback (most recent call last):
File "C:UsersOwnerAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordextcommandscore.py", line 50, in wrapped
ret = yield from coro(*args, **kwargs)
File "C:UsersOwnerDesktopcool boicoolboi.py", line 184, in play
vc = await bot.join_voice_channel(voice_channel)
File "C:UsersOwnerAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordclient.py", line 3209, in join_voice_channel
voice = VoiceClient(**kwargs)
File "C:UsersOwnerAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordvoice_client.py", line 217, in __init__
raise RuntimeError("PyNaCl library needed in order to use voice")
RuntimeError: PyNaCl library needed in order to use voice
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:UsersOwnerAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordextcommandsbot.py", line 846, in process_commands
yield from command.invoke(ctx)
File "C:UsersOwnerAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordextcommandscore.py", line 374, in invoke
yield from injected(*ctx.args, **ctx.kwargs)
File "C:UsersOwnerAppDataLocalProgramsPythonPython36-32libsite-packagesdiscordextcommandscore.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice
代码是
@bot.command(pass_context=True)
async def play(ctx):
url = ctx.message.content
url = url.strip('👌 play ')
author = ctx.message.author
voice_channel = author.voice_channel
vc = await bot.join_voice_channel(voice_channel)
player = await vc.create_ytdl_player(url)
player.start()
PyNaCl library needed in order to use voice
您需要安装 PyNaCl 库才能使用语音功能。 跑
python3 -m pip install -U discord.py[voice]
来安装它。