RuntimeError:需要 PyNaCI 库才能使用语音

Nis*_*ani 2 python discord.py

Traceback (most recent call last):
  File "C:\Users\Pradeep Tejwani\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Pradeep Tejwani\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 797, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Pradeep Tejwani\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 92, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice
Run Code Online (Sandbox Code Playgroud)

这是我的错误,即使我已经安装了 pythonpynacldiscord.py[voice]。我尝试了很多次但仍然遇到同样的错误。我什至将我的库更新到了新版本,但没有任何改变。

代码:

@bot.command()
async def join(ctx):
    channel = ctx.message.author.voice.channel
    voice = get(bot.voice_clients, guild=ctx.guild)

    if voice and voice.is_connected():
        await voice.move_to(channel)
    else:
        voice = await channel.connect()

    await voice.disconnect()

    if voice and voice.is_connected():
        await voice.move_to(channel)
    else:
        voice = await channel.connect()
        print(f"The bot has connected to {channel}\n")

    await ctx.send(f"Joined {channel}")

#leave cmd
@bot.command()
async def leave(ctx):
    channel = ctx.message.author.voice.channel
    voice = get(bot.voice_clients, guild=ctx.guild)

    if voice and voice.is_connected():
        await voice.disconnect()
        print(f"The bot has left {channel}")
        await ctx.send(f"Left {channel}")
    else:
        print("Bot was told to leave voice channel, but was not in one")
        await ctx.send("Don't think I am in a voice channel")
Run Code Online (Sandbox Code Playgroud)

Rap*_*iel 5

你安装PyNaCI了吗?如果没有,请从PyPi下载 PyNaCI 或安装discord.py 的语音版本或者并将其输入到您的控制台

python3 -m pip install -U Discord.py[语音]

还有一个小注意事项:Discord.py 现在是版本 1.5.1(我不知道你是否是最新的),PyNaCl 现在版本是 >1.4.0