Hy
I want to make a discord bot in python, that can connected to voice channel. My code:
@client.command()
async def join(ctx):
channel = ctx.author.voice
if str(channel) == 'None':
await ctx.channel.send(':x: You have to be in a voice channel to use this command. :x:')
else:
channel = ctx.author.voice.channel
await channel.connect()
This error is displayed
Ignoring exception in command join:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 25, in join
await channel.connect()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 1150, in connect
voice = cls(client, self)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/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
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, 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
If anyone has an idea, thank you very much
question from:
https://stackoverflow.com/questions/65892213/discord-bot-cant-connected-to-voice-channel-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…