python - RuntimeError:使用语音需要 PyNaCl 库
问题描述
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
这是我的错误,即使我同时安装了 pythonpynacl
库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")
解决方案
推荐阅读
- mobile - 基于移动的内部工具的技术堆栈
- android - 在 android studio 3.0.2 的命令行上打开 android sqlite 数据库文件
- php - 如何在 PHP 中创建一个返回 Json 的 Restful Web 服务
- asterisk - 星号回铃音录音
- ubuntu - 了解 Gitlab 中的所有 LDAP 用户
- java - 列表
- > 未序列化
- azure - Microsoft Azure 认知服务手写检测边界框参数
- node.js - AWS Lambda HTTPS 请求 - 蓝图
- firebase - 目标 URI 不存在:'package:firebase_database/firebase_database.dart';
- c# - Gtk# TreeView 保持选中行