gpt4 book ai didi

python - 运行时错误 : PyNaCl library needed in order to use voice

转载 作者:行者123 更新时间:2023-12-02 02:39:19 28 4
gpt4 key购买 nike

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

这是我的错误,即使我同时安装了 python 库 pynacldiscord.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")

最佳答案

你安装了 PyNaCl 了吗?如果没有,请从 PyPi 下载 PyNaCl。或者安装 Voice Version discord.py的或者在你的控制台输入这个

python3 -m pip install -U discord.py[voice]

还有一个小提示:Discord.py 现在是 1.5.1 版(我不知道你是不是最新的),PyNaCl 现在是 >1.4.0 版

关于python - 运行时错误 : PyNaCl library needed in order to use voice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63859231/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com