Discord.py Bot不离开语音 Channels

我试图编写一个discord.py机器人目前,我试图让机器人离开 Channels 时遇到问题 . 我一直在网上寻找并且无法找到我的问题的解决方案 .

我正在使用的图书馆:

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

我正在使用的代码:

@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."

我收到的错误消息:

忽略命令summon中的异常Traceback(最近一次调用最后一次):

文件“C:\ Program Files(x86)\ Python36-32 \ lib \ site-packages \ discord \ ext \ commands \ core.py”,第50行,包裹的ret =来自coro的产量(* args,** kwargs)

文件“A:/ Python / MossyBot / Bot Version 1.0.py”,第53行,在summon vc = await client.join_voice_channel(channel)

文件“C:\ Program Files(x86)\ Python36-32 \ lib \ site-packages \ discord \ client.py”,第3209行,在join_voice_channel中语音= VoiceClient(** kwargs)

文件"C:\Program Files (x86)\Python36-32\lib\site-packages\discord\voice_client.py",第217行,在 init 中引发RuntimeError("PyNaCl library needed in order to use voice")

RuntimeError:需要PyNaCl库才能使用语音

回答(0)