我正在尝试为我的Discord bot做一个测试命令,这样它就可以加入VC并播放我设置的URL。我遇到了代码问题,请帮助我。
代码如下:
# test vc join
@bot.command()
async def test_join(ctx):
url = adhan_media
guild = ctx.guild
channel = ctx.author.voice.channel
try:
await channel.connect()
await ctx.send(f"I can join voice channels!")
print(f"Successfully joined voice chanel {channel} in {guild}")
player.play(url)
except Exception as e:
await ctx.send(f"Voice chat test unsuccessful.")
print(f"Could not join voice channel {channel} in {guild} due to the following error: {e}")
if channel == None:
await ctx.send(f"You are not in a voice channel!")
print(f"Bot did not join voice channel in {guild} due to {ctx.author} not being in voice chat.")
这是我得到的错误:discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'pynacl' is not defined
我期望它加入语音聊天并播放提供的网址,但它没有。
1条答案
按热度按时间q43xntqr1#
pip install pynacl
如果需要:
import nacl