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库pynacl和discord.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")发布于 2020-10-02 11:46:40
你安装PyNaCl了吗?如果未安装,请从PyPi下载PyNaCl或安装discord.py或的Voice Version,然后在控制台中键入以下内容
python3 -m pip install -U discord.pyvoice
注意: Discord.py现在是1.5.1版(我不知道您是否更新了),而PyNaCl现在是1.4.0以上的版本
发布于 2021-09-02 09:57:45
你必须安装PyNaCl才能正常工作!您可以在终端中尝试使用pip install PyNaCl或pip3 install PyNaCl,也可以尝试将以下代码片段粘贴到代码顶部:
import os, platform
try:
import nacl
except ImportError:
try:
if platform.system().lower().startswith('win'):
os.system("pip install pynacl")
else:
os.system("pip3 install pynacl")
except Exception as e:
print("Error:", e)
exit()如果这段代码丢失了,它将被下载!
https://stackoverflow.com/questions/63859231
复制相似问题