我最近开始在 Python 上制作 Discord 机器人,我想创建一个音乐播放选项,所以我使用了需要库“PyNaCl”的函数“connect()”,所以我安装了该库并将其导入我的Python 程序,但是当我调用 connect() 函数时,出现以下错误:
Traceback (most recent call last):
File "C:\Users\Triplaqs\Documents\BOT DISCORD\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Triplaqs\Documents\BOT DISCORD\Bot Discord.py", line 92, in on_message
await message.author.voice.channel.connect()
File "C:\Users\Triplaqs\Documents\BOT DISCORD\discord\abc.py", line 1277, in connect
voice = cls(client, self)
File "C:\Users\Triplaqs\Documents\BOT DISCORD\discord\voice_client.py", line 199, in __init__
raise RuntimeError("PyNaCl library needed in order to use voice")
RuntimeError: PyNaCl library needed in order to use voice
但是我确实导入了 nacl 库。如何使用 connect() 函数?
顺便说一下,这是我的节目音乐部分:
if message.content.startswith("!play") or message.content.startswith("!p"):
if len(message.content.split())==1 :
await message.channel.send("no song given")
elif message.author.voice==None:
await message.channel.send("request user is not in a voice channel")
else:
VC=message.author.voice.channel
await message.author.voice.channel.connect()
谢谢阅读,
三板。