I am trying to code a discord.py bot but I ran into an issue while trying to get the bot to leave the voice channel. I have been looking online and haven't been able to find a working solution to my problem.
The Libraries that I am using:
import discord
import asyncio
import random
import time
import youtube_dl
from discord.ext import commands
from discord.ext.commands import Bot
from discord import Game
from discord import opus
The code that I am using:
@client.command(pass_context=True)
async def summon(ctx):
channel = ctx.message.author.voice.voice_channel
vc = await client.join_voice_channel(channel)
@client.command(name = "check", pass_context=True)
async def check(ctx):
server = ctx.message.server
if client.is_voice_connected(server):
await client.say("Yes")
else:
await client.say("No")
@client.command(pass_context=True)
async def leave(ctx):
for x in client.voice_clients:
if(x.server == ctx.message.server):
return await x.discconect()
return await client.say("Mission Failed."
The error message that I am getting:
Ignoring exception in command summon
Traceback (most recent call last):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
ret = yield from coro(*args, **kwargs)
File "A:/Python/MossyBot/Bot Version 1.0.py", line 53, in summon
vc = await client.join_voice_channel(channel)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\discord\client.py", line 3209, in join_voice_channel
voice = VoiceClient(**kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\discord\voice_client.py", line 217, in __init__
raise RuntimeError("PyNaCl library needed in order to use voice")
RuntimeError: PyNaCl library needed in order to use voice
pynacl
? – Patrick Haugh